From 3d88f52213691a68608c1842edb0921f9b5ccd9f Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Wed, 7 Apr 2021 11:11:48 +0100 Subject: [PATCH] StringFlexibleDecodable -> HTTPHeaderDecodable --- Sources/SotoCore/Encoder/DictionaryDecoder.swift | 9 +++++---- Sources/SotoCore/Message/AWSResponse.swift | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/SotoCore/Encoder/DictionaryDecoder.swift b/Sources/SotoCore/Encoder/DictionaryDecoder.swift index 0d517401f..a6a0cc293 100644 --- a/Sources/SotoCore/Encoder/DictionaryDecoder.swift +++ b/Sources/SotoCore/Encoder/DictionaryDecoder.swift @@ -1036,7 +1036,7 @@ extension __DictionaryDecoder { if let number = value as? NSNumber { return number } - return (value as? StringFlexibleDecodable)?.asNumber() + return (value as? HTTPHeaderDecodable)?.asNumber() } /// Returns the given value unboxed from a container. @@ -1046,7 +1046,7 @@ extension __DictionaryDecoder { if let bool = value as? Bool { return bool } - if let bool = (value as? StringFlexibleDecodable)?.asBool() { + if let bool = (value as? HTTPHeaderDecodable)?.asBool() { return bool } throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value) @@ -1291,7 +1291,7 @@ extension __DictionaryDecoder { if let string = value as? String { return string } - if let string = (value as? StringFlexibleDecodable)?.asString() { + if let string = (value as? HTTPHeaderDecodable)?.asString() { return string } throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value) @@ -1463,7 +1463,8 @@ internal extension DecodingError { } } -internal struct StringFlexibleDecodable { +/// Used to decode HTTP header values which could be either number, boolean or string +internal struct HTTPHeaderDecodable { let value: String init(_ string: String) { diff --git a/Sources/SotoCore/Message/AWSResponse.swift b/Sources/SotoCore/Message/AWSResponse.swift index 1db8fa608..0c282d31a 100644 --- a/Sources/SotoCore/Message/AWSResponse.swift +++ b/Sources/SotoCore/Message/AWSResponse.swift @@ -169,7 +169,7 @@ public struct AWSResponse { outputDict[headerParams[index].key] = value continue } - outputDict[headerParams[index].key] = StringFlexibleDecodable(stringValue) + outputDict[headerParams[index].key] = HTTPHeaderDecodable(stringValue) } } // add status code to output dictionary