unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Sunjoong Lee <sunjoong@gmail.com>
To: guile-user@gnu.org
Subject: Re: read-response-body of (web response) depends on Content-Length but ...
Date: Fri, 27 Apr 2012 20:08:42 +0900	[thread overview]
Message-ID: <CAK93xhpnh1Uh4qx+zrsS+tofVdkpP55rqHTu3sVbce6fZPmBWw@mail.gmail.com> (raw)
In-Reply-To: <CAK93xhqc1wjo-J_W+qxZW_NNXYhBLLP8WsY-Wc9Ri+NF1+b9EQ@mail.gmail.com>

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

The urgent patch posted before makes a bug, so I cancel it and repost:
########## cut here ##########
--- /usr/share/guile/2.0/web/response.scm 2012-04-22 04:36:06.753878689
+0900
+++ response.scm 2012-04-27 19:54:55.539304271 +0900
@@ -217,13 +217,16 @@
 (define (read-response-body r)
   "Reads the response body from @var{r}, as a bytevector.  Returns
 @code{#f} if there was no response body."
+  (let ((te (response-transfer-encoding r)))
+    (if (and te (eq? 'chunked (car (car te))))
+        (get-bytevector-all (response-port r))
   (let ((nbytes (response-content-length r)))
     (and nbytes
          (let ((bv (get-bytevector-n (response-port r) nbytes)))
            (if (= (bytevector-length bv) nbytes)
                bv
                (bad-response "EOF while reading response body: ~a bytes of
~a"
-                            (bytevector-length bv) nbytes))))))
+                            (bytevector-length bv) nbytes))))))))

 (define (write-response-body r bv)
   "Write @var{body}, a bytevector, to the port corresponding to the HTTP
@@ -269,6 +272,7 @@
 (define-response-accessor content-type #f)
 (define-response-accessor expires #f)
 (define-response-accessor last-modified #f)
+(define-response-accessor transfer-encoding #f)

 ;; Response headers
 ;;
########## cut here ##########

2012/4/27 Sunjoong Lee <sunjoong@gmail.com>
>
>  +(define-response-accessor transfer-encoding '())
>
2012/4/27 Sunjoong Lee <sunjoong@gmail.com>
>
>> I googled and found http://tools.ietf.org/html/rfc2616 .
>>
>> In a section of "4.4 Message Length":
>>   2.If a Transfer-Encoding header field (section 14.41) is present and
>>      has any value other than "identity", then the transfer-length is
>>      defined by use of the "chunked" transfer-coding (section 3.6),
>>      unless the message is terminated by closing the connection.
>>   3.If a Content-Length header field (section 14.13) is present, its
>>      decimal value in OCTETs represents both the entity-length and the
>>      transfer-length. The Content-Length header field MUST NOT be sent
>>      if these two lengths are different (i.e., if a Transfer-Encoding
>>      header field is present). If a message is received with both a
>>      Transfer-Encoding header field and a Content-Length header field,
>>      the latter MUST be ignored.
>>
>

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

  reply	other threads:[~2012-04-27 11:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27  8:04 read-response-body of (web response) depends on Content-Length but Sunjoong Lee
2012-04-27  8:28 ` Sunjoong Lee
2012-04-27 10:00   ` Sunjoong Lee
2012-04-27 11:08     ` Sunjoong Lee [this message]
2012-04-27 12:35       ` Sunjoong Lee
2012-04-27 11:32   ` Daniel Hartwig

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=CAK93xhpnh1Uh4qx+zrsS+tofVdkpP55rqHTu3sVbce6fZPmBWw@mail.gmail.com \
    --to=sunjoong@gmail.com \
    --cc=guile-user@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).