From 748cff67d89dab59799244d648598c1c8eafa223 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 7 Jul 2020 20:19:56 +0200 Subject: 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). --- aws/request.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'aws') 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 +;;; Copyright © 2019, 2020 Ricardo Wurmus ;;; ;;; 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)) -- cgit v1.2.3