Hi,

When http-client receives a 304 Not Modified response it tries to
read-string until the end of the connection. 304 Not Modified responses
must not have a body and therefore, on keep-alive connections, the read
hangs until it times out.

Here we present a patch that handles this case and also handles the
similar 204 No Content reply.

We don't bother to handle the similar, but different, 1xx series of
responses because they are complicated in other, more interesting, ways.


Thanks are due to Moritz Heidkamp for helping to read the HTTP spec.




Regards,
@ndy

-- 
andy...@ashurst.eu.org
http://www.ashurst.eu.org/
0x7EBA75FF

diff -urp http-client.orig/http-client.scm http-client/http-client.scm
--- http-client.orig/http-client.scm	2012-11-01 17:21:35.235798044 +0000
+++ http-client/http-client.scm	2012-11-01 17:23:42.023706895 +0000
@@ -497,6 +497,15 @@
                            (close-connection! con)))))
         (process-set-cookie! con (request-uri req) response)
         (case (response-code response)
+	 ;; RFC 2616, Section 4.4: Any response which MUST NOT include a message body
+	 ((204 304)
+	  (cleanup! #f)
+	  (http-client-error
+	    'send-request
+	    (sprintf "Server Response: ~A ~A"
+		     (response-code response) (response-reason response))
+	    (list (request-uri req) response)
+	    'unexpected-server-response))
           ;; TODO: According to spec, we should provide the user with a choice
           ;; when it's not a GET or HEAD request...
           ((301 302 303 307)
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to