diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2020-07-07 20:19:56 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2020-07-07 20:19:56 +0200 |
commit | 748cff67d89dab59799244d648598c1c8eafa223 (patch) | |
tree | 0ab26bae780fdd82ffb095369854778ef08edff4 /aws | |
parent | 061cd2b037df1d817c5babc904c2c7794e327a8f (diff) |
aws/request: Overwrite (web http)'s DEFAULT-VAL-WRITER.
The DEFAULT-VAL-WRITER procedure in Guile's (web http) module causes
values in headers to be quoted when they contain a semicolon.
The Authorization header that AWS expects contains a field
SignedHeaders whose value is a semicolon-separated list of header
names. When this list is quoted AWS considers the opening quote
character to be part of the name of the first header and the closing
quote character to be part of the name of the last header.
* aws/request.scm (my-default-val-writer): New procedure; replace the
definition of DEFAULT-VAL-WRITER in Guile's (web http).
Diffstat (limited to 'aws')
-rw-r--r-- | aws/request.scm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/aws/request.scm b/aws/request.scm index 5773398..abaabb7 100644 --- a/aws/request.scm +++ b/aws/request.scm @@ -1,5 +1,5 @@ ;;; guile-aws --- Scheme DSL for the AWS APIs -;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net> +;;; Copyright © 2019, 2020 Ricardo Wurmus <rekado@elephly.net> ;;; ;;; Guile-AWS is free software: you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published @@ -47,6 +47,18 @@ (define (hexify bv) (format #f "~{~2,'0x~}" (bytevector->u8-list bv))) +;; XXX: Guile's default-val-writer corrupts the Authorization header, +;; because it wraps the value of the SignedHeaders field in quotes. +;; This confuses AWS. +(define (my-default-val-writer k val port) + (if (or (string-index val #\,) + (string-index val #\")) + ((@@ (web http) write-qstring) val port) + ((@@ (web http) put-string) port val))) +(module-set! + (resolve-module '(web http)) + 'default-val-writer my-default-val-writer) + ;; See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html (define* (serialize-aws-value thing #:key (path '()) n (depth 0)) |