docs/Structs/HTTPHeader.html
public struct HTTPHeader : Equatable, Hashable, Sendable
extension HTTPHeader: CustomStringConvertible
A representation of a single HTTP header’s name / value pair.
`
name
`
Name of the header.
Swift
public let name: String
`
value
`
Value of the header.
Swift
public let value: String
`
init(name:value:)
`
Creates an instance from the given name and value.
Swift
public init(name: String, value: String)
| name |
The name of the header.
|
| value |
The value of the header.
|
`
description
`
Swift
public var description: String { get }
`
accept(_:)
`
Returns an Accept header.
Swift
public static func accept(_ value: String) -> HTTPHeader
| value |
The Accept value.
|
The header.
`
acceptCharset(_:)
`
Returns an Accept-Charset header.
Swift
public static func acceptCharset(_ value: String) -> HTTPHeader
| value |
The Accept-Charset value.
|
The header.
`
acceptLanguage(_:)
`
Returns an Accept-Language header.
Alamofire offers a default Accept-Language header that accumulates and encodes the system’s preferred languages. Use HTTPHeader.defaultAcceptLanguage.
Swift
public static func acceptLanguage(_ value: String) -> HTTPHeader
| value |
The Accept-Language value.
|
The header.
`
acceptEncoding(_:)
`
Returns an Accept-Encoding header.
Alamofire offers a default accept encoding value that provides the most common values. Use HTTPHeader.defaultAcceptEncoding.
Swift
public static func acceptEncoding(_ value: String) -> HTTPHeader
| value |
The Accept-Encoding value.
|
The header
`
authorization(username:password:)
`
Returns a Basic Authorization header using the username and password provided.
Swift
public static func authorization(username: String, password: String) -> HTTPHeader
| username |
The username of the header.
|
| password |
The password of the header.
|
The header.
`
authorization(bearerToken:)
`
Returns a Bearer Authorization header using the bearerToken provided.
Swift
public static func authorization(bearerToken: String) -> HTTPHeader
| bearerToken |
The bearer token.
|
The header.
`
authorization(_:)
`
Returns an Authorization header.
Alamofire provides built-in methods to produce Authorization headers. For a Basic Authorization header use HTTPHeader.authorization(username:password:). For a Bearer Authorization header, use HTTPHeader.authorization(bearerToken:).
Swift
public static func authorization(_ value: String) -> HTTPHeader
| value |
The Authorization value.
|
The header.
`
contentDisposition(_:)
`
Returns a Content-Disposition header.
Swift
public static func contentDisposition(_ value: String) -> HTTPHeader
| value |
The Content-Disposition value.
|
The header.
`
contentEncoding(_:)
`
Returns a Content-Encoding header.
Swift
public static func contentEncoding(_ value: String) -> HTTPHeader
| value |
The Content-Encoding.
|
The header.
`
contentType(_:)
`
Returns a Content-Type header.
All Alamofire ParameterEncodings and ParameterEncoders set the Content-Type of the request, so it may not be necessary to manually set this value.
Swift
public static func contentType(_ value: String) -> HTTPHeader
| value |
The Content-Type value.
|
The header.
`
userAgent(_:)
`
Returns a User-Agent header.
Swift
public static func userAgent(_ value: String) -> HTTPHeader
| value |
The User-Agent value.
|
The header.
`
websocketProtocol(_:)
`
Returns a Sec-WebSocket-Protocol header.
Swift
public static func websocketProtocol(_ value: String) -> HTTPHeader
| value |
The Sec-WebSocket-Protocol value.
|
The header.
`
defaultAcceptEncoding
`
Returns Alamofire’s default Accept-Encoding header, appropriate for the encodings supported by particular OS versions.
See the Accept-Encoding HTTP header documentation .
Swift
public static let defaultAcceptEncoding: HTTPHeader
`
defaultAcceptLanguage
`
Returns Alamofire’s default Accept-Language header, generated by querying Locale for the user’s preferredLanguages.
See the Accept-Language HTTP header documentation.
Swift
public static let defaultAcceptLanguage: HTTPHeader
`
defaultUserAgent
`
Returns Alamofire’s default User-Agent header.
See the User-Agent header documentation.
Example: iOS Example/1.0 (org.alamofire.iOS-Example; build:1; iOS 13.0.0) Alamofire/5.0.0
Swift
public static let defaultUserAgent: HTTPHeader