Structure
Headers
public struct Headers: Component
A struct
defining the request
headers for a given endpoint.
Defaults to empty.
Relationships
Conforms To
Component
A
protocol
defining a unique identifier for a specific request component.
Initializers
init(_:)
public init(_ headers: [String: String])
Init.
Parameters
Name | Type | Description |
---|---|---|
headers | [String: String] |
The request headers for a given endpoint. |
init(_:)
public init(_ headers: [String: String?])
Init.
Parameters
Name | Type | Description |
---|---|---|
headers | [String: String?] |
The request headers for a given endpoint. |
init(_:forKey:)
public init(_ value: String, forKey key: String)
Init.
Parameters
Name | Type | Description |
---|---|---|
value | String |
A |
key | String |
A |
init(_:forKey:)
public init(_ value: String?, forKey key: String)
Init.
Parameters
Name | Type | Description |
---|---|---|
value | String? |
An optional |
key | String |
A |
init(_:)
public init<C: Sequence>(_ keysAndValues: C) where C.Element == (String, String)
Init.
-
parameters uniqueKeysAndValues: A sequence of unique
String
tuples of request header keys and values.
init(keys:values:)
public init<K: Sequence, V: Sequence>(keys: K, values: V) where K.Element == String, V.Element == String
Init.
Parameters
Name | Type | Description |
---|---|---|
keys | K |
A sequence of unique |
values | V |
A sequence of |
Properties
defaultValue
public static var defaultValue: Headers
The default value when no cached component can be found.
Methods
inherit(from:_:)
public mutating func inherit(from original: any Component)
Inherit some previously cached value.
Headers("value1", forKey: "key1")
Headers("value2", forKey: "key2")
would be resolved to ["key1": "value1", "key2": "value2"]
.
Parameters
Name | Type | Description |
---|---|---|
original | any |
The original value for the cached component. |
update(_:)
public func update(_ request: inout URLRequest)
Update a given URLRequest
.
Parameters
Name | Type | Description |
---|---|---|
request | inout URLRequest |
A mutable |