cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HTTP POST: Determining whether a file could be found

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 9 Sep 2002 09:36:22 +0200 (MET DST)

On Sun, 8 Sep 2002, Holger Rauch wrote:

> I'm using libcurl version 7.9.8 on Solaris 8 (64bit). The code fragment
> shown below (similar to what has been suggested in the libcurl guide) is
> used to post an XML file to the server
> (curl_easy_init() omitted). However, I'm getting a message from the server
> telling me that it didn't receive anything. Thus, my questions are:
>
> 1. How can I determine whether the XML file has actually been read on the
> client side and output its contents on the screen? (Even though
> CURLOPT_VERBOSE it set to TRUE, I can only see the header fields.)

libcurl will return an error message if it fails to read the file or fails to
send it. So unless it returns error, it has sent it.

Also, try using the CURLOPT_DEBUGFUNCTION for very detailed information on
what is sent or received. It gives more information than plain VERBOSE does.

> 2. Presently, the XML file is transferred "as is" (i.e. without any special
> URL encoding taking place, "<" signs are NOT substituted by &gt;, etc.). Is
> this wrong? Does the file have to be URL encoded to be "seen" by the
> server?

libcurl doesn't translate it in any way, so you should make sure to have it
encoded exactly the same way you want it to appear in the other end.

> headers = curl_slist_append( headers,
> "Content-Type: multipart/form-data" );
> headers = curl_slist_append( headers, "Accept: text/xml" );
> curl_formadd( &post, &last,
> CURLFORM_COPYNAME, "xml-file-upload",
> CURLFORM_FILECONTENT, "./testdoc.xml",
> CURLFORM_CONTENTHEADER, headers,
> CURLFORM_END );

This looks wrong. Why would you want those weirdo headers for this particular
form field?

Content-Type: multipart/form-data is used by default for multipart formposts,
but for the request-headers not this single form field.

'Accept: text/xml' - I can't see any reason why you need it, but if you do,
you should probably set it using CURLOPT_HTTPHEADER to control the HTTP
request.

-- 
 Daniel Stenberg -- curl related mails on curl related mailing lists please
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
Received on 2002-09-09