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

Merge branch 'stable-2.0'

Conflicts:
	libguile/read.c
	test-suite/tests/web-response.test
This commit is contained in:
Mark H Weaver 2014-01-21 03:57:04 -05:00
commit ba578eb044
12 changed files with 120 additions and 38 deletions

View file

@ -4218,9 +4218,11 @@ when none is available, reading FILE-NAME with READER."
srfi-23 ;; `error` procedure
srfi-30 ;; nested multi-line comments
srfi-39 ;; parameterize
srfi-46 ;; basic syntax-rules extensions
srfi-55 ;; require-extension
srfi-61 ;; general cond clause
srfi-62 ;; s-expression comments
srfi-87 ;; => in case clauses
srfi-105 ;; curly infix expressions
))

View file

@ -1,6 +1,6 @@
;;; HTTP response objects
;; Copyright (C) 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
;; Copyright (C) 2010, 2011, 2012, 2013, 2014 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
@ -246,16 +246,21 @@ closes PORT, unless KEEP-ALIVE? is true."
bytes-read len))
(define (read! bv start count)
(let ((ret (get-bytevector-n! port bv start count)))
(if (eof-object? ret)
(if (= bytes-read len)
0
(fail))
(begin
(set! bytes-read (+ bytes-read ret))
(if (> bytes-read len)
(fail)
ret)))))
;; Read at most LEN bytes in total. HTTP/1.1 doesn't say what to do
;; when a server provides more than the Content-Length, but it seems
;; wise to just stop reading at LEN.
(let ((count (min count (- len bytes-read))))
(let loop ((ret (get-bytevector-n! port bv start count)))
(cond ((eof-object? ret)
(if (= bytes-read len)
0 ; EOF
(fail)))
((and (zero? ret) (> count 0))
;; Do not return zero since zero means EOF, so try again.
(loop (get-bytevector-n! port bv start count)))
(else
(set! bytes-read (+ bytes-read ret))
ret)))))
(define close
(and (not keep-alive?)