1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 13:30:26 +02:00

read-response-body always returns bytevector or #f

* module/web/response.scm (read-response-body): Fix to always return
  either a bytevector or #f.  Previously, reading a 0-length body could
  return the EOF object.
This commit is contained in:
Andy Wingo 2013-01-11 11:30:29 +01:00
parent 67e5ab8ac6
commit 2ac3c0a590

View file

@ -1,6 +1,6 @@
;;; HTTP response objects
;; Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
;; Copyright (C) 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@ -294,7 +294,13 @@ response port."
(define (read-response-body r)
"Reads the response body from R, as a bytevector. Returns
#f if there was no response body."
(and=> (response-body-port r #:decode? #f) get-bytevector-all))
(let ((body (and=> (response-body-port r #:decode? #f)
get-bytevector-all)))
;; Reading a body of length 0 will result in get-bytevector-all
;; returning the EOF object.
(if (eof-object? body)
#vu8()
body)))
(define (write-response-body r bv)
"Write BV, a bytevector, to the port corresponding to the HTTP