Storage Documentation

Structure Headers

public struct Headers: Component  

A struct defining the request headers for a given endpoint. Defaults to empty.

%3 Headers Headers Component Component Headers->Component

Conforms To

Component

A protocol defining a unique identifier for a specific request component.

Initializers

init(_:​)

public init(_ headers: [String: String])  

Init.

Parameters

headers [String:​ String]

The request headers for a given endpoint.

init(_:​)

public init(_ headers: [String: String?])  

Init.

Parameters

headers [String:​ String?]

The request headers for a given endpoint.

init(_:​for​Key:​)

public init(_ value: String, forKey key: String)  

Init.

Parameters

value String

A String representing a single request header value.

key String

A String representing a single request header key.

init(_:​for​Key:​)

public init(_ value: String?, forKey key: String)  

Init.

Parameters

value String?

An optional String representing a single request header value. nil will be ignored.

key String

A String representing a single request header key.

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

keys K

A sequence of unique Strings representing request header keys.

values V

A sequence of Strings representing request header values.

Properties

default​Value

public static var defaultValue: Headers  

The default value when no cached component can be found.

value

public var value: [String: String] 

The request headers for a given endpoint.

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

original any

The original value for the cached component.

update(_:​)

public func update(_ request: inout URLRequest)  

Update a given URLRequest.

Parameters

request inout URLRequest

A mutable URLRequest.