FastCGIServerResponse

public class FastCGIServerResponse : ServerResponse

The FastCGIServerRequest class implements the ServerResponse protocol for incoming HTTP requests that come in over a FastCGI connection.

Usage Example:

 //Create a `FastCGIServerResponse` object with socket and request parameters.
 let response = FastCGIServerResponse(socket: clientSocket, request: request)
 ...
 //Set the status code.
 response.statusCode = HTTPStatusCode.badRequest
 ...
 //Write a String to the `FastCGIServerResponse` object.
 try response.write(from: "Some String")
 ...
 //Stop the `FastCGIServerResponse` object.
 try response.end()
  • The headers to send back as part of the HTTP response.

    Usage Example:

    response.headers["Content-Length"] = [String(theBody.count)]
    

    Declaration

    Swift

    public var headers: HeadersContainer
  • The status code to send in the HTTP response.

    Usage Example:

    let statusCode = response.statusCode
    

    Declaration

    Swift

    public var statusCode: HTTPStatusCode? { get set }
  • Add a string to the body of the HTTP response and complete sending the HTTP response

    Throws

    Socket.error if an error occurred while writing to the socket

    Usage Example:

    try response.end(text: result)
    

    Declaration

    Swift

    public func end(text: String) throws

    Parameters

    text

    The String to add to the body of the HTTP response.

  • Add a string to the body of the HTTP response.

    Throws

    Socket.error if an error occurred while writing to the socket

    Usage Example:

    try response.write(from: theBody)
    

    Declaration

    Swift

    public func write(from string: String) throws

    Parameters

    string

    The String data to be added.

  • Add bytes to the body of the HTTP response.

    Throws

    Socket.error if an error occurred while writing to the socket

    Usage Example:

    try response.write(from: theData)
    

    Declaration

    Swift

    public func write(from data: Data) throws

    Parameters

    data

    The Data struct that contains the bytes to be added.

  • Complete sending the HTTP response

    Throws

    Socket.error if an error occurred while writing to a socket

    Usage Example:

    try response.end()
    

    Declaration

    Swift

    public func end() throws
  • External message write for multiplex rejection

    Usage Example:

    try response.rejectMultiplexConnecton(requestId: requestId)
    

    Declaration

    Swift

    public func rejectMultiplexConnecton(requestId: UInt16) throws

    Parameters

    requestId

    The id of the request to reject.

  • External message write for role rejection

    Usage Example:

    try response.rejectUnsupportedRole()
    

    Declaration

    Swift

    public func rejectUnsupportedRole() throws
  • Reset the request for reuse in Keep alive

    Usage Example:

    response?.responseBuffers.reset()
    

    Declaration

    Swift

    public func reset()