cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Endless waiting on POST with zero content length

From: Emil Romanus <sdac.bithack_at_gmail.com>
Date: Thu, 5 Jul 2007 20:05:59 +0200

Problem solved! Did the following:
curl_easy_setopt(q->client, CURLOPT_POSTFIELDSIZE, 0);

No difference at all on the headers sent during my request and response. It
must be something with libcurls internals, I would consider this a bug,
right? Or perhaps just bad use of the CURLOPT_POSTFIELDS option (see below)?

Let me explain a little:
The first request used CURLOPT_POSTFIELDS... The second request set that
same option to NULL. This must have confused libcurl, resulting in libcurl
having no idea how to calculate the content length.

2007/7/5, Emil Romanus <sdac.bithack_at_gmail.com>:
>
> Hey everyone,
>
> I am experiencing a problem when performing two POST's in a row to two
> separate files. This is an exact description of what I perform:
>
> First of all, I contact a PHP-script named "login.php ". My request looks
> like this according to libcurl verbose:
> * Connected to localhost (127.0.0.1) port 80 (#0)
> > POST /lanelogic-test/botnet/login.php HTTP/1.1
> Host: localhost
> Accept: */*
> Content-Length: 33
> Content-Type: application/x-www-form-urlencoded
>
> The content is filled with a login name and a password only. This is
> probably irrelevant. Return looks like this:
> < HTTP/1.1 200 OK
> < Date: Thu, 05 Jul 2007 15:17:34 GMT
> < Server: Apache
> < X-Powered-By: PHP/5.2.2-pl1-gentoo
> < Methanol-Status: 0
> < Content-Length: 48
> < Content-Type: text/html
> <
>
> Alright, so in conclusion: My first request uploads data of length 33, and
> as a return I get data with a length of 48. Everything works just fine until
> the next time I perform a post.
>
> This time, it reuses the same connection, requests another file, uploads
> data with ZERO length (A POST without content), and the server returns ZERO
> content. This is also WHAT I EXPECT it to do, nothing wrong with it. Request
> and response looks like this:
> * Re-using existing connection! (#0) with host localhost
> * Connected to localhost (127.0.0.1) port 80 (#0)
> > POST /lanelogic-test/botnet/fetch.php HTTP/1.1
> Host: localhost
> Accept: */*
> Cookie: METHASESSID=4465b37ce4c2755d263920795674e76f
> Content-Length: 0
> Content-Type: application/x-www-form-urlencoded
>
> Response:
>
> < HTTP/1.1 200 OK
> < Date: Thu, 05 Jul 2007 15:17:34 GMT
> < Server: Apache
> < X-Powered-By: PHP/5.2.2-pl1-gentoo
> < Content-Length: 0
> < Content-Type: text/html
> <
>
> However, this is where the problem is. It stops, waiting for data maybe?
> But the server said Content-length is zero. Libcurl uses 0 % CPU, and by
> sending a SIGINT I can (almost) traceback where it's stopped:
> #0 0x00002afa0a840970 in read () from /lib/libc.so.6
> #1 0x00002afa0a7f5a63 in ?? () from /lib/libc.so.6
> #2 0x00002afa0a7ebe98 in fread () from /lib/libc.so.6
> #3 0x00002afa0a55a937 in Curl_fillreadbuffer () from
> /usr/lib/libcurl.so.4
> #4 0x00002afa0a55b6fb in Curl_readwrite () from /usr/lib/libcurl.so.4
> #5 0x00002afa0a55cf5f in Curl_perform () from /usr/lib/libcurl.so.4
>
> What do you guys think? libcurl version is 7.16.3. I know it might seem
> weird that I POST zero data, but just nevermind that, that's how I want it
> to work -- Always work through POST and deny GET-requests (to avoid database
> usage and session lookup and other things when someone tries browsing the
> URL through a web browser).
>
> Thanks in advance.
> Emil
Received on 2007-07-05