docs/docsets/Kitura.docset/Contents/Resources/Documents/Structs/Headers.html
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
Swift
public mutating func append(_ key: String, value: String)
| 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
Swift
public var startIndex: HeadersIndex { get }
`
endIndex
`
The ending index of the Headers collection
Swift
public var endIndex: HeadersIndex { get }
`
HeadersIndex
`
The type of an Index of the Headers collection.
Swift
public typealias HeadersIndex = HeadersContainer.Index
`
subscript(_:)
`
Get the value of a HTTP header
Swift
public subscript(key: String) -> String? { get set }
| key |
The HTTP header key whose value is to be retrieved
|
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.
Swift
public subscript(position: HeadersIndex) -> (String, String?) { get }
| position |
The position in the Headers collection of the (key, value) tuple to return.
|
A (key, value) tuple.
`
index(after:)
`
Get the next Index in the Headers collection after the one specified.
Swift
public func index(after i: HeadersIndex) -> HeadersIndex
The Index in the Headers collection after the one specified.
`
setLocation(_:)
`
Sets the Location HTTP header
Swift
public mutating func setLocation(_ path: String)
| path |
the path to set into the header or the special reserved word “back”.
|
`
setType(_:charset:)
`
Sets the Content-Type HTTP header
Swift
public mutating func setType(_ type: String, charset: String? = nil)
| 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.
Swift
public mutating func addAttachment(for filePath: String? = nil)
| for |
The file to set the filename to
|
`
addLink(_:linkParameters:)
`
Adds a link with specified parameters to Link HTTP header
Swift
public mutating func addLink(_ link: String, linkParameters: [LinkParameter : String])
| link |
link value
|
| linkParameters |
The link parameters (according to RFC 5988) with their values
|