Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

HTTPHeaders

mattt edited this page Sep 18, 2020 · 4 revisions

HTTPHeaders

An order-preserving and case-insensitive representation of HTTP headers.

public struct HTTPHeaders

Inheritance

Collection, CustomStringConvertible, ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral, Sequence

Initializers

init()

Creates an empty instance.

public init()

init(_:​)

Creates an instance from an array of HTTPHeaders. Duplicate case-insensitive names are collapsed into the last name and value encountered.

public init(_ headers:[HTTPHeader])

init(_:​)

Creates an instance from a [String:​ String]. Duplicate case-insensitive names are collapsed into the last name and value encountered.

public init(_ dictionary:[String:​ String])

init(dictionaryLiteral:​)

public init(dictionaryLiteral elements:(String, String))

init(arrayLiteral:​)

public init(arrayLiteral elements:​ HTTPHeader)

Properties

dictionary

The dictionary representation of all headers.

var dictionary:[String:​ String]

This representation does not preserve the current order of the instance.

startIndex

var startIndex:​ Int

endIndex

var endIndex:​ Int

description

var description:​ String

`default`

The default set of HTTPHeaders used by Alamofire. Includes Accept-Encoding, Accept-Language, and User-Agent.

let `default`:​ HTTPHeaders = [.defaultAcceptEncoding,
                                         .defaultAcceptLanguage,
                                         .defaultUserAgent]

Methods

add(name:​value:​)

Case-insensitively updates or appends an HTTPHeader into the instance using the provided name and value.

public mutating func add(name:​ String, value:​ String)

Parameters

  • name:​ The HTTPHeader name.
  • value:​ The `HTTPHeader value.

add(_:​)

Case-insensitively updates or appends the provided HTTPHeader into the instance.

public mutating func add(_ header:​ HTTPHeader)

Parameters

  • header:​ The HTTPHeader to update or append.

update(name:​value:​)

Case-insensitively updates or appends an HTTPHeader into the instance using the provided name and value.

public mutating func update(name:​ String, value:​ String)

Parameters

  • name:​ The HTTPHeader name.
  • value:​ The `HTTPHeader value.

update(_:​)

Case-insensitively updates or appends the provided HTTPHeader into the instance.

public mutating func update(_ header:​ HTTPHeader)

Parameters

  • header:​ The HTTPHeader to update or append.

remove(name:​)

Case-insensitively removes an HTTPHeader, if it exists, from the instance.

public mutating func remove(name:​ String)

Parameters

  • name:​ The name of the HTTPHeader to remove.

sort()

Sort the current instance by header name.

public mutating func sort()

sorted()

Returns an instance sorted by header name.

public func sorted() -> HTTPHeaders

Returns

A copy of the current instance sorted by name.

value(for:​)

Case-insensitively find a header's value by name.

public func value(for name:​ String) -> String?

Parameters

  • name:​ The name of the header to search for, case-insensitively.

Returns

The value of header, if it exists.

makeIterator()

public func makeIterator() -> IndexingIterator<[HTTPHeader]>

index(after:​)

public func index(after i:​ Int) -> Int
Types
Protocols
Global Typealiases
Clone this wiki locally