curl-library
C API questions
Date: Wed, 4 Dec 2002 11:19:12 +0100
Hi there,
I have a few questions concerning the libcurl C Interface:
I got a running C Client using sockets which talks with a webservice via
HTTP using a SOAP attachment and
a XML attachment. You can find the orginal source code of this client under
http://cvs.x-act.org/cgi-bin/viewcvs.cgi/xact_client_adv_c/src/xclient.c?rev
=1.3&content-type=text/vnd.viewcvs-markup
it send messages like this to the webservice:
<snip>
POST http://www.x-act.org:8080/conversion HTTP/1.0
User-Agent: "xact_client_adv_php V1.11"
Host: www.x-act.org
Content-Type: multipart/related; type="text/xml";
boundary="==7b6db914c4d750a6773afdc5f8cdf8a9=="
Content-Length: 1002
SOAPAction: ""
--==7b6db914c4d750a6773afdc5f8cdf8a9==
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<m:msgID
xmlns:m="http://www.x-act.org">php-3aea18c9cb28e9a23f249dc34d41ec7d</m:msgID
>
</soap-env:Header>
<soap-env:Body>
<m:DoAdvancedConversion xmlns:m="http://www.x-act.org">
<sourceformat>xcbl</sourceformat>
<sourceschema>foo</sourceschema>
<targetformat>oagis</targetformat>
<targetschema>foo2</targetschema>
<area>hospital</area>
<documenttype>purchase</documenttype>
<usergroup>business</usergroup>
<username>anonymous</username>
<password>dummy_at_dummy.de</password>
</m:DoAdvancedConversion>
</soap-env:Body>
</soap-env:Envelope>
--==7b6db914c4d750a6773afdc5f8cdf8a9==
Content-Type: application/xml
<root>
<element1>wort 1</element1>
<element2>wort 2</element2>
</root>
--==7b6db914c4d750a6773afdc5f8cdf8a9==--
</snip>
(1)
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 now file
size limit for the xml attachment.
As far I understood the examples there is no possibility for streaming/using
sockets - you only can use
strings which (as far as I know) are restricted to 64k in pure C.
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.
Guess CURLOPT_CUSTOMREQUEST wont work in this case anymore...
(2)
so I played a little bit around
<snip>
...
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);
/* Header */
headers = curl_slist_append(headers, "Pragma:");
headers = curl_slist_append(headers, "Accept:");
headers = curl_slist_append(headers, "SOAPAction: \"\"");
headers = curl_slist_append(headers, "User-Agent:
\"xact_client_adv_c V1.1 (Linux)(SSL)\"");
headers = curl_slist_append(headers, "Host: www.x-act.org");
headers = curl_slist_append(headers, "SOAPAction: \"\"");
headers = curl_slist_append(headers, "Content-Type:
multipart/related; type=\"text/xml\";");
curl_formadd(&post, &last, CURLFORM_COPYNAME, "soap",
CURLFORM_COPYCONTENTS, soap,
CURLFORM_CONTENTTYPE, "text/xml",
CURLFORM_END);
curl_formadd(&post, &last, CURLFORM_COPYNAME, "xml",
CURLFORM_COPYCONTENTS, xml,
CURLFORM_CONTENTTYPE, "application/xml",
CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
res = curl_easy_perform(curl);
...
</snip>
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?
(3)
If I use CURLOPT_VERBOSE I only see the send header - is there a way to see
the full body too?
Thank you for any answers
Greetings Robert
-------------------------------------------------------
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?micr0003en
Received on 2002-12-04