cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl, squid proxy, failing multipart post

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Thu, 12 May 2005 00:11:45 +0200 (CEST)

On Wed, 11 May 2005 man_at_tfhs.net wrote:

> purely my lack of understanding the code. i see a bit more now, and can say
> that the function Curl_http_auth_act() is getting called, and does change
> the conn struct to indicate that the connect is over and the newurl should
> be used. but, the code continues and runs the if((k->keepon & KEEP_WRITE) &&
> (select_res & CSELECT_OUT)){}, which attempts a write on the closed connect.

The code makes no attempt to stop the post. libcurl will attempt to send the
data of the size it has claimed it will send.

I consider the premature closure a bad behavior in the proxy, and indeed a
failed treatment by libcurl. Have you tried 7.14.0-pre2 BTW? I've added a
check for this error in there.

> perhaps at the time that the auth code says i should use a different url, we
> could rewind and break out of this loop, or should we return to the caller?
> i do not see exactly where the re-transmit with auth happens currently...

The re-transmit happens when the current transfer (both upload and download)
is complete. See the Curl_perform() function and consider that Transfer()
returns when the transfer is complete (or failed).

> and yes, this does look like a mine field.

The problem here really is that the proxy resets the connection and the
failure this should cause.

If the proxy hadn't reset the connection, libcurl would continue and send it
again with the proper auth header.

But of course, if libcurl receives a 407 while doing an "upload" and it
contains a Proxy-Connection: close, we could stop the upload and return and
consider the transfer complete. This would then simply cause the internal auth
loop and the next request will be issued with the proper auth headers.

I would rather have you work on a fix like that, since I have no way of
repeating the problem and the test suite's HTTP server is far too simple to
allow me to write up a test case that repeats this or even something similar.

Add a check for 407 and conn->bits.close near the check for 100 in
lib/transfer.c (like around line 470 or so). Start by removing the KEEP_WRITE
bit from the k->keepon variable...

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-05-12