From f76045415285d49ffe60f117a620ac2dee8a051c Mon Sep 17 00:00:00 2001 From: Michal Herda Date: Wed, 4 Feb 2026 15:16:24 +0100 Subject: [PATCH] Encode {PROXY-,}BASIC-AUTHORIZATION using the default external format Fixes #152 --- docs/index.html | 4 ++++ docs/index.xml | 6 +++++- request.lisp | 20 ++++++++++++-------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/docs/index.html b/docs/index.html index 00da1c4..671c3c4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -935,6 +935,8 @@

Requests

NIL, should be a list of two strings (username and password) which will be sent to the server for basic authorization. + Its encoding is affected by + *drakma-default-external-format*.

@@ -972,6 +974,8 @@

Requests

denoting the port to use (which will default to 80 otherwise). Defaults to *default-http-proxy*. + Its encoding is affected by + *drakma-default-external-format*. proxy-basic-authorization is used like basic-authorization, but for the proxy, and only if proxy is true. If diff --git a/docs/index.xml b/docs/index.xml index f2677b3..d4729ea 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -608,7 +608,7 @@ T

The canonical location for the latest version of Drakma is http://weitz.de/files/drakma.tar.gz. + href="https://github.com/edicl/drakma/releases">https://github.com/edicl/drakma/releases.

@@ -915,6 +915,8 @@ T NIL, should be a list of two strings (username and password) which will be sent to the server for basic authorization. + Its encoding is affected by + *drakma-default-external-format*.

@@ -952,6 +954,8 @@ T denoting the port to use (which will default to 80 otherwise). Defaults to *default-http-proxy*. + Its encoding is affected by + *drakma-default-external-format*. proxy-basic-authorization is used like basic-authorization, but for the proxy, and only if proxy is true. If diff --git a/request.lisp b/request.lisp index e281c01..39880af 100644 --- a/request.lisp +++ b/request.lisp @@ -712,16 +712,20 @@ Any encodings in Transfer-Encoding, such as chunking, are always performed." (write-header "User-Agent" "~A" (user-agent-string user-agent))) (when basic-authorization (write-header "Authorization" "Basic ~A" - (base64:string-to-base64-string - (format nil "~A:~A" - (first basic-authorization) - (second basic-authorization))))) + (base64:usb8-array-to-base64-string + (string-to-octets + (format nil "~A:~A" + (first basic-authorization) + (second basic-authorization)) + :external-format *drakma-default-external-format*)))) (when (and proxy proxy-basic-authorization) (write-header "Proxy-Authorization" "Basic ~A" - (base64:string-to-base64-string - (format nil "~A:~A" - (first proxy-basic-authorization) - (second proxy-basic-authorization))))) + (base64:usb8-array-to-base64-string + (string-to-octets + (format nil "~A:~A" + (first proxy-basic-authorization) + (second proxy-basic-authorization)) + :external-format *drakma-default-external-format*)))) (when accept (write-header "Accept" "~A" accept)) (when range