cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: HTTP Post and Curl

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 10 Jun 2003 14:00:38 +0200 (CEST)

On Tue, 10 Jun 2003 Vassilevich_Misha_at_emc.com wrote:

Again, the curl-library list is a lot better suited for this kind of
questions, and that's where the crowd of libcurl-using programmers are. Since
you insist on keeping it here, I'll reply here.

> headers = curl_slist_append(headers, "POST /servlets/CelerraManager
> HTTP/1.0");

This is not a "header" in curl speak, this is the request line and you cannot
append this as a header without causing libcurl to send an invalid request. I
realize the docs could be a bit clearer on this.

Read the docs, examples and tutorial and look for CURLOPT_POST,
CURLOPT_POSTFIELDS, CURLOPT_HTTPVERSION, CURLOPT_URL and possibly
CURLOPT_CUSTOMREQUEST for options that control this first request line.

Are you sure you must force it to use HTTP 1.0?

> headers = curl_slist_append(headers, "Host: XXX.24.179.XX:8000");

You'd only need to set the Host: header if the host and port is any different
than the one used in the URL.

> headers = curl_slist_append(headers, "Content-Length: 388");

This header too is set by libcurl automaticly if you just provide the correct
info with CURLOPT_POSTFIELDS or CURLOPT_POSTFIELDSIZE.

> int test = curl_easy_perform(curl);

You didn't set any URL. That is the *only* required option you must set.

> I am getting all the time error code 3 which is "The URL was not properly
> formatted" .

Right, it was completly missing!

-- 
 Daniel Stenberg -- curl: been grokking URLs since 1998
-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
Received on 2003-06-10