unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Nala Ginrut <nalaginrut@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: [PATCH] read-response-body should return received data when error occcurs (V2)
Date: Fri, 16 Mar 2012 13:45:13 +0800	[thread overview]
Message-ID: <CAPjoZofm0trkzaYxVzK6y5vjmQOqeUddqHQeJ0mRoRzoVowfJw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]

From 183abb7e7d649fe4a1d1799b97e6da96f51b683c Mon Sep 17 00:00:00 2001
From: NalaGinrut <NalaGinrut@gmail.com>
Date: Fri, 16 Mar 2012 13:41:34 +0800
Subject: [PATCH] read-response-body returns received data when error occurs

---
 module/web/response.scm |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/module/web/response.scm b/module/web/response.scm
index 07e1245..5c6861a 100644
--- a/module/web/response.scm
+++ b/module/web/response.scm
@@ -228,12 +228,12 @@ This is true for some response types, like those with
code 304."
   "Reads the response body from @var{r}, as a bytevector.  Returns
 @code{#f} if there was no response body."
   (let ((nbytes (response-content-length r)))
-    (and nbytes
-         (let ((bv (get-bytevector-n (response-port r) nbytes)))
-           (if (= (bytevector-length bv) nbytes)
-               bv
+    (and nbytes
+         (let* ((bv (get-bytevector-n (response-port r) nbytes)))
+           (if (eof-object? bv)
                (bad-response "EOF while reading response body: ~a bytes of
~a"
-                            (bytevector-length bv) nbytes))))))
+                            0 nbytes)
+               bv)))))

 (define (write-response-body r bv)
   "Write @var{bv}, a bytevector, to the port corresponding to the HTTP
-- 
1.7.0.4

[-- Attachment #2: Type: text/html, Size: 1662 bytes --]

             reply	other threads:[~2012-03-16  5:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16  5:45 Nala Ginrut [this message]
2012-03-16  5:54 ` [PATCH] read-response-body should return received data when error occcurs (V2) Nala Ginrut
2012-03-16  5:56   ` Nala Ginrut
2012-03-16  7:32   ` Daniel Hartwig
2012-03-16  8:47     ` Nala Ginrut
2012-03-16 16:27       ` Tristan Colgate
2012-03-17  2:26         ` Nala Ginrut
2012-03-16 16:57 ` Ian Price
2012-03-16 17:25   ` Daniel Hartwig
2012-03-17  1:46     ` Nala Ginrut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPjoZofm0trkzaYxVzK6y5vjmQOqeUddqHQeJ0mRoRzoVowfJw@mail.gmail.com \
    --to=nalaginrut@gmail.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).