unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Alexey Abramov via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" <bug-guile@gnu.org>
To: 51133@debbugs.gnu.org
Subject: bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase
Date: Mon, 11 Oct 2021 09:03:55 +0200	[thread overview]
Message-ID: <20211011070355.20408-1-levenson@mmer.org> (raw)

* module/web/http.scm (read-response-line): Use the end of the string,
in case a line doesn't have char-set:whitespace at the end.
* test-suite/tests/web-http.test ("read-response-line"): Add test.
---
 module/web/http.scm            | 6 ++++--
 test-suite/tests/web-http.test | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/module/web/http.scm b/module/web/http.scm
index 4276e1744..7443bd6a4 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -1187,8 +1187,10 @@ values: the HTTP version, the response code, and the (possibly empty)
 \"reason phrase\"."
   (let* ((line (read-header-line port))
          (d0 (string-index line char-set:whitespace)) ; "delimiter zero"
-         (d1 (and d0 (string-index line char-set:whitespace
-                                   (skip-whitespace line d0)))))
+         (d1 (and d0 (or (string-index line char-set:whitespace
+                                       (skip-whitespace line d0))
+                         ;; tolerate responses with empty "reason phrase"
+                         (string-length line)))))
     (unless (and d0 d1)
       (bad-response "Bad Response-Line: ~s" line))
     (values (parse-http-version line 0 d0)
diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test
index 63377349c..6d8cd1642 100644
--- a/test-suite/tests/web-http.test
+++ b/test-suite/tests/web-http.test
@@ -216,6 +216,8 @@
 
   ;; Empty reason phrases are valid; see <http://bugs.gnu.org/22273>.
   (pass-if-read-response-line "HTTP/1.1 302 "
+                              (1 . 1) 302 "")
+  (pass-if-read-response-line "HTTP/1.1 302"
                               (1 . 1) 302 ""))
 
 (with-test-prefix "write-response-line"
-- 
2.31.1






             reply	other threads:[~2021-10-11  7:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11  7:03 Alexey Abramov via Bug reports for GUILE, GNU's Ubiquitous Extension Language [this message]
2021-10-12  8:01 ` bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase jakub-w
2021-10-12  8:26   ` Alexey Abramov via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2021-10-12  9:11     ` tomas
2021-10-12 10:03     ` jakub-w
2021-10-12 14:35       ` Alexey Abramov via Bug reports for GUILE, GNU's Ubiquitous Extension Language

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=20211011070355.20408-1-levenson@mmer.org \
    --to=bug-guile@gnu.org \
    --cc=51133@debbugs.gnu.org \
    --cc=levenson@mmer.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).