aws/request: Only process server response if it exists.
authorRicardo Wurmus <rekado@elephly.net>
Wed, 3 Mar 2021 21:55:44 +0000 (22:55 +0100)
committerRicardo Wurmus <rekado@elephly.net>
Wed, 3 Mar 2021 21:55:44 +0000 (22:55 +0100)
aws/request.scm

index e8ade5cf90ee8ca09b3076d7af0a56a65c9a4494..f9662b83c45050c483e28e552d43c3ce97faac00 100644 (file)
@@ -336,11 +336,14 @@ corresponding value in INPUT."
         (let ((server-text (match body
                              ((? bytevector? bv)
                               (utf8->string bv))
-                             ((? string? s) s))))
+                             ((? string? s) s)
+                             (anything anything))))
           (match (response-content-type response)
             ((or ('application/x-amz-json-1.1 . rest)
                  ('application/json . rest))
-             (json-string->scm server-text))
+             (or (and=> server-text json-string->scm)
+                 #true))
             (('text/xml . rest)
-             (xml->sxml server-text))
+             (or (and=> server-text xml->sxml)
+                 #true))
             (_ server-text)))))))