cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl misses end of request data before reading response (patch)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 4 Jun 2015 23:26:09 +0200 (CEST)

On Thu, 4 Jun 2015, Frank Meier wrote:

> The behaviour was that the keep-alive connection was droped by libcurl after
> a POST request that was answered by a 4xx error response from the server.
> The curl debug message read "HTTP error before end of send, stop sending"
> which suggests, that the reply from the server was sent before curl was
> aware the "request sending" was finished.

I'm not sure I fully get why this is a problem.

Yes, it means that it disconnects a connection that it could otherwise keep
open - but it would waste time and bandwidth by sending data that the server
(obviously) doesn't care about.

I pretty sure this is done on purpose.

> This is indeed the case: Curl detects that all request data has been sent
> when the READFUNCTION returns '0', but this happens only after curl tries to
> read the response from the server, which is already available, since from
> the servers perspective the request is complete at this point.

No, the server sends the error before the full request has been sent. That's
perfectly legitimate for a server to do.

> So I'd propose 2 patches:
> 1) also respect CURLOPT_POSTFIELDSIZE as an information for the size of the
> request body, and therefore improve the detection when "request sending" is
> finished.

I'm probably stupid but I don't understand the problem you want to fix.

If you want to prevent libcurl from acting on the error that the server sends
before the full request is sent, then _that_ should be changed not the end of
request detection.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-06-04