cURL / Mailing Lists / curl-library / Single Mail

curl-library

form POST problems with 64 bit Linux build ?

From: Stephen Collyer <scollyer_at_netspinner.co.uk>
Date: Thu, 17 Jul 2008 10:54:21 +0100

1. I have a client who has built some code on a 64 bit Suse 10.3
installation, and has run into a problem with the POST logic.

2. The curl build info as reported by curl -V is:

> curl 7.18.0 (i686-pc-linux-gnu) libcurl/7.16.4 OpenSSL/0.9.8e zlib/1.2.3 libidn/1.0
> Protocols: tftp ftp telnet dict ldap http file https ftps
> Features: IDN IPv6 Largefile NTLM SSL libz

3. The code that performs the POST is as follows:

> struct curl_httppost *formpost = NULL;
> struct curl_httppost *lastptr = NULL;
> struct curl_slist *headerlist = NULL;
>
> CURLcode result;
>
> foreach (QString content_key, content.keys())
> {
> QByteArray element_name = content_key.toUtf8();
> QByteArray element_contents = content[content_key].toUtf8();
>
> curl_formadd(&formpost,
> &lastptr,
> CURLFORM_COPYNAME, element_name.data(),
> CURLFORM_NAMELENGTH, element_name.size(),
> CURLFORM_COPYCONTENTS, element_contents.data(),
> CURLFORM_CONTENTSLENGTH, element_contents.size(),
> CURLFORM_END);
> }
>
> headerlist = curl_slist_append(headerlist, "Expect:");
>
> QByteArray url_array(url.toEncoded().data());
> char *curl_url = url_array.data();
>
> common_curl_setup(curl_);
>
> curl_easy_setopt(curl_, CURLOPT_URL, curl_url);
> curl_easy_setopt(curl_, CURLOPT_HTTPHEADER, headerlist);
> curl_easy_setopt(curl_, CURLOPT_HTTPPOST, formpost);
>
> result = curl_easy_perform(curl_);
> curl_formfree(formpost);
> curl_slist_free_all(headerlist);

4. The problem is that libcurl emits a valid header, but with
no POST data, and a content-length header of 0, thus:

> POST /mdp/api HTTP/1.1
> Host: 192.168.1.59:18082
> Accept: */*
> Content-Length: 0

Logging code (which I've removed from the code above) shows
that elements are indeed added to the form via the foreach
loop.

5. The same code works perfectly on a 32 bit Opensuse 10,3
installation with the same libcurl version i.e. it emits
the POST data as well as the header.

So my question is: are there known POST problems with 64 bit
libcurl 7.16.4, and is the problem likely to go away with a
newer version, or have I run into something new ?

Or is there some subtle error in the way that I'm constructing
the form perhaps, that hasn't shown up until now ?

-- 
Regards
Steve Collyer
Netspinner Ltd
Received on 2008-07-17