unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* url-http: Unexpected reuse of connection
@ 2006-11-15  3:07 Shun-ichi GOTO
  2006-11-26 13:25 ` Magnus Henoch
  0 siblings, 1 reply; 2+ messages in thread
From: Shun-ichi GOTO @ 2006-11-15  3:07 UTC (permalink / raw)


I experienced unexpected (invalid) re-use of connection on accessing
via proxy server.

When we use url function with proxy, request is made with
"Connection: close", but url-http-parse-header<f> close connection 
only if

 "Connection:" header is in response
 AND
 its value is "close".

I think it should be corrected to:

 "Connection:" header is NOT in response
 OR
 its value is "close".

In actual case, my proxy server doesn't return "Connection" header.
Therefore, url-http-parse-header<f> leaves the connection.
Then url-http-find-free-connection<f> find and reuse the connection
when its sentinel is not yet run (process status is 'open).
Finaly, 2nd url-retrieve<f> call very after 1st call
sends request into closed (not sentinel'ed) connection, and fail.

# Yes, I think this is rare timing case.

Here is a patch:
Index: url-http.el
===================================================================
--- url-http.el	(revision 4177)
+++ url-http.el	(working copy)
@@ -391,8 +391,8 @@
   (mail-narrow-to-head)
   ;;(narrow-to-region (point-min) url-http-end-of-headers)
   (let ((connection (mail-fetch-field "Connection")))
-    (if (and connection
-	     (string= (downcase connection) "close"))
+    (if (or (null connection)
+	    (string= (downcase connection) "close"))
 	(delete-process url-http-process)))
   (let ((class nil)
 	(success nil))

--- Regards,
 Shun-ichi Goto  <gotoh@taiyo.co.jp>
   R&D Group, TAIYO Corp., Tokyo, JAPAN

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: url-http: Unexpected reuse of connection
  2006-11-15  3:07 url-http: Unexpected reuse of connection Shun-ichi GOTO
@ 2006-11-26 13:25 ` Magnus Henoch
  0 siblings, 0 replies; 2+ messages in thread
From: Magnus Henoch @ 2006-11-26 13:25 UTC (permalink / raw)


Shun-ichi GOTO <gotoh@taiyo.co.jp> writes:

> I experienced unexpected (invalid) re-use of connection on accessing
> via proxy server.
>
> When we use url function with proxy, request is made with
> "Connection: close", but url-http-parse-header<f> close connection 
> only if
>
>  "Connection:" header is in response
>  AND
>  its value is "close".
>
> I think it should be corrected to:
>
>  "Connection:" header is NOT in response
>  OR
>  its value is "close".
>
> In actual case, my proxy server doesn't return "Connection" header.
> Therefore, url-http-parse-header<f> leaves the connection.
> Then url-http-find-free-connection<f> find and reuse the connection
> when its sentinel is not yet run (process status is 'open).
> Finaly, 2nd url-retrieve<f> call very after 1st call
> sends request into closed (not sentinel'ed) connection, and fail.

This varies by HTTP version.  It seems to me that your proxy server
uses HTTP 1.0, and therefore doesn't send "Connection: close", since
keeping the connection alive is not the default.  I just committed a
patch that makes the behavior depend on HTTP version.  Does it fix
your problem?

Magnus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-11-26 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-15  3:07 url-http: Unexpected reuse of connection Shun-ichi GOTO
2006-11-26 13:25 ` Magnus Henoch

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).