From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] web: send capitalized authorization header scheme Date: Fri, 24 Jun 2022 09:05:05 -0700 Message-ID: <20220624160505.18005-1-aconchillo@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32520"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Fri Jun 24 18:08:33 2022 Return-path: Envelope-to: guile-devel@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 1o4lr8-00083y-55 for guile-devel@m.gmane-mx.org; Fri, 24 Jun 2022 18:08:26 +0200 Original-Received: from localhost ([::1]:46602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4lr6-0001n0-Su for guile-devel@m.gmane-mx.org; Fri, 24 Jun 2022 12:08:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4lo7-0006OO-SK for guile-devel@gnu.org; Fri, 24 Jun 2022 12:05:19 -0400 Original-Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:51969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4lo6-0004J9-13 for guile-devel@gnu.org; Fri, 24 Jun 2022 12:05:19 -0400 Original-Received: by mail-pj1-x1035.google.com with SMTP id l2so2021932pjf.1 for ; Fri, 24 Jun 2022 09:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ocd7LUqnAGjfNII8cxH+Rwk8vAYiqWSQ/V75YsZ13J0=; b=dPYtq41g6puvoOeqrC/wAS9JgYvvkYgNSma8iburLvWhyp4poh0vCJsq4kQhhnMaXG q42zbUIw3hio2ygdp+aHGx3h/mDK85Lomr79z4O3g4CGjzmXAz/7n+2es0pIydZDvGRJ WApTLlL/RCeNobN+6eA+az3amiaPaI+b7T4oT3cyG4iIL0OhDxoE/T9aJpe/tWyiKXFo ih2LACGAuqke/hkH8pHxMIiiCHTLPP8ahoCp4xwzn6D6PEHtcM50/4R9m6iSAWrZW8LJ pW5KIf+2FctBoEb3CfpdHfACpfyXsrFPusghdeAkNLCe1P0+08mvjVEQhO3T8hsakwg8 X5tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ocd7LUqnAGjfNII8cxH+Rwk8vAYiqWSQ/V75YsZ13J0=; b=Of0RV84Le6v/RB6bN5Z1mzTKAIEFpj0FzhlnMPOzirWnmS7qzjC1aTr6kMTrEbOWFx zbHhMEdgn82SjqGyhdTvqz4hwzNhPBzwohn7V/NxttWfBVYA62pZwE/Mc9d35M2g5KPK hibdm6qlIofEtreLB8ZO9RZpj+gz2+CRqk3TYJwKilMRY5eDgEQxUrJdszuXcoq6BU4u O8y3blRpVmOqOBfl7aVlgLIFs2sRh16ZN1Aj7kzcGsT+ETD0lK6o2w2fh4zPZRTIRJHV pRjhtgE0RgnSANi4ttKoXkmI3l+bKhxe0FG0tSAbzNku3QuP+4EalCb2/b0Kf58tXN4H e8tA== X-Gm-Message-State: AJIora8dUm5f3a85Y5w/kkyxcnJ2iVg+D75G+XA+kpwPyEdE9+y03M0A mRQeyXObrh+W8xlsfO4V/sWLCvs1RrQ= X-Google-Smtp-Source: AGRyM1uojkzPOBrSsU6G7PpRoybIXAQMzTwTaJ1AMXst6d5G9bjbIuLAU0DfLylRRG6aLUCKMl10LQ== X-Received: by 2002:a17:90a:778a:b0:1ea:264c:e9af with SMTP id v10-20020a17090a778a00b001ea264ce9afmr4755814pjk.246.1656086716156; Fri, 24 Jun 2022 09:05:16 -0700 (PDT) Original-Received: from localhost (cpe-198-72-134-0.socal.res.rr.com. [198.72.134.0]) by smtp.gmail.com with UTF8SMTPSA id p47-20020a056a0026ef00b0050dc7628150sm1913598pfw.42.2022.06.24.09.05.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jun 2022 09:05:15 -0700 (PDT) X-Mailer: git-send-email 2.34.1 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=aconchillo@gmail.com; helo=mail-pj1-x1035.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21237 Archived-At: * module/web/http.scm (write-credentials): capitalize authorization header scheme. The standard allows the scheme to be case-insensitive, however most libraries out there expect the scheme to be capitalized, which is what it is actually used in RFC docs (e.g. https://datatracker.ietf.org/doc/html/rfc7617#section-2). Some libraries even reject lowercase scheme making Guile incompatible. --- module/web/http.scm | 4 ++-- test-suite/tests/web-http.test | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/module/web/http.scm b/module/web/http.scm index 4276e1744..312c28934 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -965,10 +965,10 @@ as an ordered alist." (define (write-credentials val port) (match val (('basic . cred) - (put-string port "basic ") + (put-string port "Basic ") (put-string port cred)) ((scheme . params) - (put-symbol port scheme) + (put-string port (string-titlecase (symbol->string scheme))) (put-char port #\space) (write-key-value-list params port)))) diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test index 63377349c..5c6a954b9 100644 --- a/test-suite/tests/web-http.test +++ b/test-suite/tests/web-http.test @@ -336,9 +336,14 @@ (pass-if-parse authorization "Digest foooo" '(digest foooo)) (pass-if-parse authorization "Digest foo=bar,baz=qux" '(digest (foo . "bar") (baz . "qux"))) - (pass-if-round-trip "Authorization: basic foooo\r\n") - (pass-if-round-trip "Authorization: digest foooo\r\n") - (pass-if-round-trip "Authorization: digest foo=bar, baz=qux\r\n") + (pass-if-parse authorization "basic foooo" '(basic . "foooo")) + (pass-if-parse authorization "digest foooo" '(digest foooo)) + (pass-if-parse authorization "digest foo=bar,baz=qux" + '(digest (foo . "bar") (baz . "qux"))) + (pass-if-round-trip "Authorization: Basic foooo\r\n") + (pass-if-round-trip "Authorization: Bearer token\r\n") + (pass-if-round-trip "Authorization: Digest foooo\r\n") + (pass-if-round-trip "Authorization: Digest foo=bar, baz=qux\r\n") (pass-if-parse expect "100-continue, foo" '((100-continue) (foo))) (pass-if-parse from "foo@bar" "foo@bar") (pass-if-parse host "qux" '("qux" . #f)) -- 2.34.1