ServerRequest

public protocol ServerRequest : AnyObject

The ServerRequest protocol allows requests to be abstracted across different networking protocols in an agnostic way to the Kitura project Router.

  • The set of headers received with the incoming request

    Declaration

    Swift

    var headers: HeadersContainer { get }
  • The URL from the request in string form This contains just the path and query parameters starting with ‘/’ Use ‘urlURL’ for the full URL

    Declaration

    Swift

    @available(*, deprecated, message: "This contains just the path and query parameters starting with '/'. use 'urlURL' instead")
    var urlString: String { get }
  • url

    The URL from the request in UTF-8 form This contains just the path and query parameters starting with ‘/’ Use ‘urlURL’ for the full URL

    Declaration

    Swift

    var url: Data { get }
  • The URL from the request as URLComponents URLComponents has a memory leak on linux as of swift 3.0.1. Use ‘urlURL’ instead

    Declaration

    Swift

    @available(*, deprecated, message: "URLComponents has a memory leak on linux as of swift 3.0.1. use 'urlURL' instead")
    var urlComponents: URLComponents { get }
  • The URL from the request

    Declaration

    Swift

    var urlURL: URL { get }
  • The IP address of the client

    Declaration

    Swift

    var remoteAddress: String { get }
  • Major version of HTTP of the request

    Declaration

    Swift

    var httpVersionMajor: UInt16? { get }
  • Minor version of HTTP of the request

    Declaration

    Swift

    var httpVersionMinor: UInt16? { get }
  • The HTTP Method specified in the request

    Declaration

    Swift

    var method: String { get }
  • Read data from the body of the request

    Throws

    Socket.error if an error occurred while reading from the socket

    Declaration

    Swift

    func read(into data: inout Data) throws -> Int

    Parameters

    data

    A Data struct to hold the data read in.

    Return Value

    The number of bytes read

  • Read a string from the body of the request.

    Throws

    Socket.error if an error occurred while reading from the socket

    Declaration

    Swift

    func readString() throws -> String?

    Return Value

    An Optional string

  • Read all of the data in the body of the request

    Throws

    Socket.error if an error occurred while reading from the socket

    Declaration

    Swift

    func readAllData(into data: inout Data) throws -> Int

    Parameters

    data

    A Data struct to hold the data read in.

    Return Value

    The number of bytes read