mirror of
https://github.com/apple/swift-http-structured-headers
synced 2026-11-25 04:47:48 +00:00
Add support for encoding/decoding binary data
This commit is contained in:
1 parent
5aaca631da
commit
b797a6ff50
11 files changed
+211
-12
No files matched your search
@@ -11,6 +11,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
import Foundation
|
||||
import StructuredHeaders
|
||||
|
||||
private let keyedInnerListDecoderSupportedKeys = ["items", "parameters"]
|
||||
@@ -52,7 +53,13 @@ extension KeyedInnerListDecoder: KeyedDecodingContainerProtocol {
|
||||
defer {
|
||||
self.decoder.pop()
|
||||
}
|
||||
return try type.init(from: self.decoder)
|
||||
|
||||
if type is Data.Type {
|
||||
let container = try self.decoder.singleValueContainer()
|
||||
return try container.decode(Data.self) as! T
|
||||
} else {
|
||||
return try type.init(from: self.decoder)
|
||||
}
|
||||
}
|
||||
|
||||
func nestedContainer<NestedKey: CodingKey>(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer<NestedKey> {
|
||||
|
||||
Reference in new issue
Block a user