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

HTTPHeader

mattt edited this page Sep 18, 2020 · 4 revisions

HTTPHeader

A representation of a single HTTP header's name / value pair.

public struct HTTPHeader:​ Hashable

Inheritance

CustomStringConvertible, Hashable

Initializers

init(name:​value:​)

Creates an instance from the given name and value.

public init(name:​ String, value:​ String)

Parameters

  • name:​ The name of the header.
  • value:​ The value of the header.

Properties

name

Name of the header.

let name:​ String

value

Value of the header.

let value:​ String

description

var description:​ String

defaultAcceptEncoding

Returns Alamofire's default Accept-Encoding header, appropriate for the encodings supported by particular OS versions.

let defaultAcceptEncoding:​ HTTPHeader

See the Accept-Encoding HTTP header documentation .

defaultAcceptLanguage

Returns Alamofire's default Accept-Language header, generated by querying Locale for the user's preferredLanguages.

let defaultAcceptLanguage:​ HTTPHeader

See the Accept-Language HTTP header documentation.

defaultUserAgent

Returns Alamofire's default User-Agent header.

let defaultUserAgent:​ HTTPHeader

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

Methods

accept(_:​)

Returns an Accept header.

public static func accept(_ value:​ String) -> HTTPHeader

Parameters

  • value:​ The Accept value.

Returns

The header.

acceptCharset(_:​)

Returns an Accept-Charset header.

public static func acceptCharset(_ value:​ String) -> HTTPHeader

Parameters

  • value:​ The Accept-Charset value.

Returns

The header.

acceptLanguage(_:​)

Returns an Accept-Language header.

public static func acceptLanguage(_ value:​ String) -> HTTPHeader

Alamofire offers a default Accept-Language header that accumulates and encodes the system's preferred languages. Use HTTPHeader.defaultAcceptLanguage.

Parameters

  • value:​ The Accept-Language value.

Returns

The header.

acceptEncoding(_:​)

Returns an Accept-Encoding header.

public static func acceptEncoding(_ value:​ String) -> HTTPHeader

Alamofire offers a default accept encoding value that provides the most common values. Use HTTPHeader.defaultAcceptEncoding.

Parameters

  • value:​ The Accept-Encoding value.

Returns

The header

authorization(username:​password:​)

Returns a Basic Authorization header using the username and password provided.

public static func authorization(username:​ String, password:​ String) -> HTTPHeader

Parameters

  • username:​ The username of the header.
  • password:​ The password of the header.

Returns

The header.

authorization(bearerToken:​)

Returns a Bearer Authorization header using the bearerToken provided

public static func authorization(bearerToken:​ String) -> HTTPHeader

Parameters

  • bearerToken:​ The bearer token.

Returns

The header.

authorization(_:​)

Returns an Authorization header.

public static func authorization(_ value:​ String) -> HTTPHeader

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:​).

Parameters

  • value:​ The Authorization value.

Returns

The header.

contentDisposition(_:​)

Returns a Content-Disposition header.

public static func contentDisposition(_ value:​ String) -> HTTPHeader

Parameters

  • value:​ The Content-Disposition value.

Returns

The header.

contentType(_:​)

Returns a Content-Type header.

public static func contentType(_ value:​ String) -> HTTPHeader

All Alamofire ParameterEncodings and ParameterEncoders set the Content-Type of the request, so it may not be necessary to manually set this value.

Parameters

  • value:​ The Content-Type value.

Returns

The header.

userAgent(_:​)

Returns a User-Agent header.

public static func userAgent(_ value:​ String) -> HTTPHeader

Parameters

  • value:​ The User-Agent value.

Returns

The header.

Types
Protocols
Global Typealiases
Clone this wiki locally