unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase
@ 2021-10-11  7:03 Alexey Abramov via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  2021-10-12  8:01 ` jakub-w
  0 siblings, 1 reply; 6+ messages in thread
From: Alexey Abramov via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2021-10-11  7:03 UTC (permalink / raw)
  To: 51133

* 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






^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-12 14:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11  7:03 bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase Alexey Abramov via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2021-10-12  8:01 ` 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

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).