summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2021-02-25 00:22:32 +0100
committerRicardo Wurmus <rekado@elephly.net>2021-02-25 00:22:32 +0100
commita21ed8b07f5bad5621a99fef1f2f6fc86cadf895 (patch)
tree140d2aea1f84601651adb61cef970115553f9d1f
parent64e6304bc329fb013e8495d0bbfad44d730256c2 (diff)
request: Patch (web http)'s handling of the Authorization header.
* aws/request.scm: Declare a new authorization header with a writer that does not quote values.
-rw-r--r--aws/request.scm26
1 files changed, 18 insertions, 8 deletions
diff --git a/aws/request.scm b/aws/request.scm
index a88195f..d311ec2 100644
--- a/aws/request.scm
+++ b/aws/request.scm
@@ -1,5 +1,5 @@
;;; guile-aws --- Scheme DSL for the AWS APIs
-;;; Copyright © 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2019, 2020, 2021 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
@@ -26,7 +26,7 @@
#:use-module (gcrypt hmac)
#:use-module (rnrs bytevectors)
#:use-module (web client)
- #:use-module ((web http) #:select (header-writer))
+ #:use-module ((web http) #:select (header-writer declare-header!))
#:use-module (sxml simple)
#:export (make-operation->request serialize-aws-value))
@@ -51,14 +51,24 @@
;; 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)
+(define put-string (@@ (web http) put-string))
+(define put-symbol (@@ (web http) put-symbol))
+(define put-char (@@ (web http) put-char))
+(define write-qstring (@@ (web http) write-qstring))
+(define (my-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)
+ (write-qstring val port)
+ (put-string port val)))
+(declare-header! "authorization"
+ (@@ (web http) parse-credentials)
+ (@@ (web http) validate-credentials)
+ (lambda (val port)
+ (match val
+ ((scheme . params)
+ (put-symbol port scheme)
+ (put-char port #\space)
+ ((@@ (web http) write-key-value-list) params port my-val-writer)))))
;; See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html