From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alexey Abramov via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" Newsgroups: gmane.lisp.guile.bugs Subject: bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase Date: Mon, 11 Oct 2021 09:03:55 +0200 Message-ID: <20211011070355.20408-1-levenson@mmer.org> Reply-To: Alexey Abramov Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40459"; mail-complaints-to="usenet@ciao.gmane.io" To: 51133@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Mon Oct 11 09:05:14 2021 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mZpN4-000AIy-1u for guile-bugs@m.gmane-mx.org; Mon, 11 Oct 2021 09:05:14 +0200 Original-Received: from localhost ([::1]:60814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZpN2-0008Ts-2b for guile-bugs@m.gmane-mx.org; Mon, 11 Oct 2021 03:05:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZpMs-0008TB-HI for bug-guile@gnu.org; Mon, 11 Oct 2021 03:05:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZpMs-0000b1-84 for bug-guile@gnu.org; Mon, 11 Oct 2021 03:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZpMs-0003l5-1c for bug-guile@gnu.org; Mon, 11 Oct 2021 03:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alexey Abramov Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 11 Oct 2021 07:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51133 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163393586914403 (code B ref -1); Mon, 11 Oct 2021 07:05:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Oct 2021 07:04:29 +0000 Original-Received: from localhost ([127.0.0.1]:56286 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZpMK-0003kF-SW for submit@debbugs.gnu.org; Mon, 11 Oct 2021 03:04:29 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:35324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZpMH-0003k5-1a for submit@debbugs.gnu.org; Mon, 11 Oct 2021 03:04:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZpMF-00080h-R4 for bug-guile@gnu.org; Mon, 11 Oct 2021 03:04:24 -0400 Original-Received: from mail.mmer.org ([178.22.65.174]:48654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZpME-00050Q-2x for bug-guile@gnu.org; Mon, 11 Oct 2021 03:04:23 -0400 Original-Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 29d24c22 for ; Mon, 11 Oct 2021 07:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=dkim; bh=g55cgYrk7ZeTKFn4b5yQrg7N3luRB9A6Tn9wpuS1zk4=; b=R+wP oUEA9svnMFg1U/lm2V8mPDp6LWrgO1TlPfw1p6XIhayHMnL58tFwHpxZSrGUZHl+ v6krf8hYtU7qNOR3bSzg/GiLxl3/HCNw63o7qHetwXWCJRF1TaKvlnla+8wqylMW cRgq8U09fwlPhPcIbAKi1jEPZy39/hYk0shpI70= Original-Received: from delta (j74182.upc-j.chello.nl [24.132.74.182]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 4d492ff5 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Mon, 11 Oct 2021 07:04:10 +0000 (UTC) X-Mailer: git-send-email 2.31.1 Received-SPF: pass client-ip=178.22.65.174; envelope-from=levenson@mmer.org; helo=mail.mmer.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:10187 Archived-At: * 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 . (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