@@ -11,12 +11,12 @@ import Foundation
1111
1212/// HTTP headers are colon separated name-value pairs used for specifying request
1313/// details, authentication and more.
14- public struct HTTPHeader : Equatable , Hashable , HeaderConvertible {
14+ public struct HTTPHeader : Equatable , Hashable , Sendable , HeaderConvertible {
1515
1616 public let name : String
1717 public let value : String
1818
19- /// Try to initialize HTTPHeader from string value. If string value cannot be parsed
19+ /// Try to initialize `` HTTPHeader`` from string value. If string value cannot be parsed
2020 /// as a valid header, initialization fails with `nil`.
2121 /// - Parameter string: String to parse as a HTTP header
2222 public init ? ( from string: String ) {
@@ -32,7 +32,7 @@ public struct HTTPHeader: Equatable, Hashable, HeaderConvertible {
3232 self . value = String ( split [ 1 ] )
3333 }
3434
35- /// Initialize HTTPHeader from string value. String must be a valid header,
35+ /// Initialize `` HTTPHeader`` from string value. String must be a valid header,
3636 /// otherwise the initialization will trip an assertion.
3737 /// - Parameter string: String representation of a HTTP header
3838 public init ( _ string: String ) {
@@ -48,7 +48,7 @@ public struct HTTPHeader: Equatable, Hashable, HeaderConvertible {
4848 self . value = String ( split [ 1 ] )
4949 }
5050
51- /// Initialize HTTPHeader as a name-value pair.
51+ /// Initialize `` HTTPHeader`` as a name-value pair.
5252 /// - Parameters:
5353 /// - name: Name of the header (part before colon)
5454 /// - value: Value of the header (part after colon)
@@ -82,14 +82,14 @@ extension HTTPHeader: CustomStringConvertible {
8282// MARK: - HTTPHeaders
8383
8484/// A collection of multiple headers. Can contain any entities convertible to
85- /// `HTTPHeader` (`HeaderConvertible`). Final header names
85+ /// `` HTTPHeader`` (`` HeaderConvertible` `). Final header names
8686/// and values are resolved at the time the request is sent.
8787public struct HTTPHeaders : Sendable {
8888
8989 /// List of contained headers
9090 public var headers : [ any HeaderConvertible ]
9191
92- /// Create collection of `HTTPHeader`-s from key-value dictionary mapped as
92+ /// Create collection of `` HTTPHeader` `-s from key-value dictionary mapped as
9393 /// name-value header pairs.
9494 /// - Parameter headers: Dictionary, where keys are header names
9595 public init ( _ headers: [ String : String ] ) {
@@ -122,7 +122,7 @@ public struct HTTPHeaders: Sendable {
122122 }
123123
124124 /// Resolve all headers to their final values.
125- /// - Returns: Array of resolved headers as `HTTPHeader`-s
125+ /// - Returns: Array of resolved headers as `` HTTPHeader` `-s
126126 public func resolve( ) -> [ HTTPHeader ] {
127127 headers. map { $0. resolveHeader ( ) }
128128 }
@@ -197,12 +197,16 @@ extension HTTPHeaders: CustomStringConvertible {
197197
198198// MARK: - HeaderConvertible
199199
200- /// Allows conforming entities to be converted to HTTPHeader
201- /// for subsequent use in HTTP requests.
200+ /// Allows conforming entities to be converted to `` HTTPHeader``
201+ /// for use in HTTP requests.
202202public protocol HeaderConvertible : Sendable {
203203
204- /// Resolves the final name and value of the header
205- /// - Returns: Valid HTTP header name-value pair
204+ /// Resolves the final name and value of the header.
205+ ///
206+ /// This function will be called every time for each header
207+ /// before a network request is sent.
208+ ///
209+ /// - Returns: Valid HTTP header (name-value pair)
206210 func resolveHeader( ) -> HTTPHeader
207211
208212}
0 commit comments