Skip to content

Commit

Permalink
StringFlexibleDecodable -> HTTPHeaderDecodable
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Apr 7, 2021
1 parent ce219fe commit 3d88f52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Sources/SotoCore/Encoder/DictionaryDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SotoCore/Message/AWSResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3d88f52

Please sign in to comment.