Request

public class Request : Message

A class representing an HTTP request.

  • The method of the request.

    Declaration

    Swift

    let method: Method
  • url

    The requested URL.

    Declaration

    Swift

    let url: URL
  • HTTP options.

    Declaration

    Swift

    let options: String?
  • Initialize an HTTP request.

    Declaration

    Swift

    init?(withMethod method: Method, andUrl url: URL, andHeaders headers: Headers = [:], andBody body: Data = Data(), andOptions options: String? = nil)

    Parameters

    method

    The request’s HTTP method.

    url

    The requested URL.

    headers

    Headers of the request.

    body

    An optional body of the request.

    options

    Optional HTTP options.

  • Construct a HTTP CONNECT request for establishing TCP tunnels through HTTP proxy server, which supports this.

    Declaration

    Swift

    static func connect(toTarget target: Target, viaProxy proxy: Target, withHeaders headers: Headers = [:]) -> Request?

    Parameters

    target

    The target of the request, i.e., the server to which the tunnel should be established.

    proxy

    The proxy server, through which the tunnel should be established.

    headers

    The headers of the request.

    Return Value

    The request, nil if arguments are invalid.

  • Compose a request into date that can be sent to the HTTP server.

    Declaration

    Swift

    var composed: Data { get }

    Return Value

    The composed request.