[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13857: Unhandled case in module/web/response.scm

From: Andy Wingo
Subject: bug#13857: Unhandled case in module/web/response.scm
Date: Sat, 09 Mar 2013 11:15:53 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

On Sat 09 Mar 2013 02:27, Daniel Hartwig <address@hidden> writes:

> It is anyway clear that ‘response-body-port’ is missing the case where
> a content-length header is not present and the body is terminated by
> the server closing the port.  Some additional care needs to be taken,
> e.g. ‘#:keep-alive?’ is incompatible with missing content-length.
> Depending on how ‘response-body-port’ is used, I will have to consider
> whether to signal an error or do something else in that case.
> Thanks for reporting this and hopefully it can be fixed for the next
> point release.  As I am currently somewhat involved with the web
> modules and related RFCs it is something else I can work on.

Something like this?

--- a/module/web/response.scm
+++ b/module/web/response.scm
@@ -273,13 +273,26 @@ body is available.
 When KEEP-ALIVE? is #f, closing the returned port also closes R's
 response port."
   (define port
-    (if (member '(chunked) (response-transfer-encoding r))
-        (make-chunked-input-port (response-port r)
-                                 #:keep-alive? keep-alive?)
-        (let ((len (response-content-length r)))
-          (and len
-               (make-delimited-input-port (response-port r)
-                                          len keep-alive?)))))
+    (cond
+     ((member '(chunked) (response-transfer-encoding r))
+      (make-chunked-input-port (response-port r)
+                               #:keep-alive? keep-alive?))
+     ((response-content-length r)
+      => (lambda (len)
+           (make-delimited-input-port (response-port r)
+                                      len keep-alive?)))
+     ((response-must-not-include-body? r)
+      #f)
+     ((or (memq 'close (response-connection r))
+          (and (equal? (response-version r) '(1 . 0))
+               (not (memq 'keep-alive (response-connection r)))))
+      port)
+     (else
+      ;; Here we have a message with no transfer encoding, no
+      ;; content-length, and a response that won't necessarily be closed
+      ;; by the server.  Not much we can do; assume that the client
+      ;; knows how to handle it.
+      port)))
   (when (and decode? port)
     (match (response-content-type r)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]