Back to Kitura

Headers

docs/docsets/Kitura.docset/Contents/Resources/Documents/Structs/Headers.html

3.0.14.2 KB
Original Source

Headers

public struct Headers
extension Headers: Collection

The struct containing the HTTP headers and implements the headers APIs for the RouterRequest and RouterResponse classes.

`

                append(_:value:)
                `

Append values to the header

Declaration

Swift

public mutating func append(_ key: String, value: String)

Parameters

| key |

The key of the header to append a value to.

| | value |

The value to be appended to the specified header.

|

`

                startIndex
                `

The starting index of the Headers collection

Declaration

Swift

public var startIndex: HeadersIndex { get }

`

                endIndex
                `

The ending index of the Headers collection

Declaration

Swift

public var endIndex: HeadersIndex { get }

`

                HeadersIndex
                `

The type of an Index of the Headers collection.

Declaration

Swift

public typealias HeadersIndex = HeadersContainer.Index

`

                subscript(_:)
                `

Get the value of a HTTP header

Declaration

Swift

public subscript(key: String) -> String? { get set }

Parameters

| key |

The HTTP header key whose value is to be retrieved

|

Return Value

The value of the specified HTTP header, or nil, if it doesn’t exist.

`

                subscript(_:)
                `

Get a (key value) tuple from the Headers collection at the specified position.

Declaration

Swift

public subscript(position: HeadersIndex) -> (String, String?) { get }

Parameters

| position |

The position in the Headers collection of the (key, value) tuple to return.

|

Return Value

A (key, value) tuple.

`

                index(after:)
                `

Get the next Index in the Headers collection after the one specified.

Declaration

Swift

public func index(after i: HeadersIndex) -> HeadersIndex

Return Value

The Index in the Headers collection after the one specified.

`

                setLocation(_:)
                `

Sets the Location HTTP header

Declaration

Swift

public mutating func setLocation(_ path: String)

Parameters

| path |

the path to set into the header or the special reserved word “back”.

|

`

                setType(_:charset:)
                `

Sets the Content-Type HTTP header

Declaration

Swift

public mutating func setType(_ type: String, charset: String? = nil)

Parameters

| type |

The type to set in the Content-Type header

| | charset |

The charset to specify in the Content-Type header.

|

`

                addAttachment(for:)
                `

Sets the HTTP header Content-Disposition to “attachment”, optionally adding the filename parameter. If a file is specified the HTTP header Content-Type will be set based on the extension of the specified file.

Declaration

Swift

public mutating func addAttachment(for filePath: String? = nil)

Parameters

| for |

The file to set the filename to

|

`

                addLink(_:linkParameters:)
                `

Adds a link with specified parameters to Link HTTP header

Declaration

Swift

public mutating func addLink(_ link: String, linkParameters: [LinkParameter : String])

Parameters

| link |

link value

| | linkParameters |

The link parameters (according to RFC 5988) with their values

|