curl-library
Re: C API questions
Date: Wed, 4 Dec 2002 15:12:34 +0100 (MET)
On Wed, 4 Dec 2002, Robert Barsch - DOYOUWEB.DE wrote:
> Now my task is, to rewrite this C client to use HTTPS - works fine for a
> php client using cURL and the CURLOPT_CUSTOMREQUEST, cause I must limit the
> size of the attachments, so no server timeout occurs. But using pure C I
> have to watch the memory size, there should be no file size limit for the
> xml attachment.
libcurl will not allow you to do multi-part formposts easily without size
limits. The multipart formpost stuff in libcurl requires that the full post
is contructed in memory before it is sent off...
> As far I understood the examples there is no possibility for
> streaming/using sockets
I don't understand what you mean.
> you only can use strings
No, you can send away anything, including binary stuff. Whatever you please
really.
> which (as far as I know) are restricted to 64k in pure C.
They are not. You must be confusing C with something else! ;-)
> Is this right so far or did I oversee anything? (I'm anything else than a C
> guru *g*) Is there a workaround for this? How could I generate this message
> above with any XML attachment.
What are you working around? Why can't you just convert your working PHP
program into a C program doing the same thing? The interfaces are very
similar using either language.
> Guess CURLOPT_CUSTOMREQUEST wont work in this case anymore...
To do what?
> curl_easy_setopt(curl, CURLOPT_URL,
> "http://www.x-act.org:8080/conversion");
> curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
> curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
> curl_easy_setopt(curl, CURLOPT_CRLF, 1);
I don't think you really want the CURLOPT_CRLF, or do you?
> headers = curl_slist_append(headers, "Host: www.x-act.org");
libcurl would make its own Host: header, you don't need to provide it
yourself.
> headers = curl_slist_append(headers, "Content-Type:
> multipart/related; type=\"text/xml\";");
This won't work. More about this:
> there is the problem, that libcurl always overwrites my content-type with
> "Content-Type: multipart/form-data" + boundary.
> Is there a way to force a own content type eg. multipart/related for
> curl_formadd?
Nope. There's nothing that prevents us to add a system to curl where this can
be modified, but:
1. Multipart formposts as defined in RFC1867 seems to have defined that
multipart/form-data is the mime-type to use.
Also, since the boundary string is generated and used within the formdata
context, we can't just change it easily in the header only.
2. Since you have a pretty clear understanding and exact wishes of what you
want to send away, why don't you just create a big pre-formatted buffer
that looks the way you want it and do a regular POST with it? Set
CURLOPT_POST and then provide all post-data with a normal read callback.
> (3) If I use CURLOPT_VERBOSE I only see the send header - is there a way to
> see the full body too?
Yes, CURLOPT_DEBUGFUNCTION gives you the lot.
-- Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs. ------------------------------------------------------- This SF.net email is sponsored by: Microsoft Visual Studio.NET comprehensive development tool, built to increase your productivity. Try a free online hosted session at: http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003enReceived on 2002-12-04