curl-library
Re: easy API: curl_easy_perform() doesn't return after receiving all data
Date: Wed, 15 Nov 2006 15:12:41 +1100
Hi Daniel,
> > CURL info: select/poll returned error
>
> Wow. This happens when Curl_select() returns only CSELECT_ERR and I've
> actually never seen anyone experience this before.
>
> I would suggest you run this with a debugger to investigate this deeper.
I'm not getting this error anymore, but here is a typical run showing
CURLE_SEND_ERROR with the http status code 200.
C:\build\testcurl7-debug\debug>testcurl7-debug.exe
* About to connect() to api.google.com port 80 (#0)
* Trying 216.239.37.104... * connected
* Connected to api.google.com (216.239.37.104) port 80 (#0)
> POST /search/beta2 HTTP/1.1
Host: api.google.com
Accept: */*
Content-Type: text/xml; charset=utf-8
SOAPAction: urn:GoogleSearchAction
Content-Length: 879
< HTTP/1.1 200 OK
< Content-Type: text/xml; charset=utf-8
< Cache-control: private
< Transfer-Encoding: chunked
< Date: Wed, 15 Nov 2006 03:45:51 GMT
< Server: GFE/1.3
* Send failure: Connection was aborted
* failed sending data to the peer
rc != CURLE_OK
failed sending data to the peer
HTTP Status Code: 200
* Closing connection #0
C:\build\testcurl7-debug\debug>
It seems to me from tracing through that Google sends back
"<N>0<R><N>" as the last four bytes of data, where the <N> is a
newline, and the last two bytes are a carriage return and newline
(<R><N>). CURL seems to stop after the zero, seeing it needs no more
data.
But, in transfer.c, where we have:
switch (Curl_select(fd_read, fd_write, interval_ms)) {
...
}
Curl_select returns 2, and then:
default: /* readable descriptors */
result = Curl_readwrite(conn, &done);
break;
result is CURLE_SEND_ERROR.
But this is after all data is sent and received, so I'm not sure why
it's trying to send data, especially when the comments indicate it's
trying for readable descriptors.
Maybe after Google sends the 0, CURL says I've got no more stuff to
read, but later on the left-over <R><N> cause it to try and read more
data?
Attached is a minimal test programme that I used on Win32 for tracing
through the code. I put a breakpoint on my curl_writefcn. It doesn't
need to be run with any arguments.
Best,
-J
- text/plain attachment: testcurl.c