IncomingHTTPSocketProcessor

public class IncomingHTTPSocketProcessor : IncomingSocketProcessor

This class processes the data sent by the client after the data was read. The data is parsed, filling in a HTTPServerRequest object. When the parsing is complete, the ServerDelegate is invoked.

Usage Example:

 //Create an `IncomingHTTPSocketProcessor` object.
 var processor : IncomingHTTPSocketProcessor?

 //Write from an NSMutableData buffer.
 processor.write(from: NSMutableData)

 //Write from a data object.
 processor.write(from: utf8, length: utf8Length)
  • A back reference to the IncomingSocketHandler processing the socket that this IncomingDataProcessor is processing.

    Usage Example:

    processor?.handler = handler
    

    Declaration

    Swift

    public weak var handler: IncomingSocketHandler?
  • The socket if idle will be kep alive until…

    Usage Example:

    processor?.keepAliveUntil = 0.0
    

    Declaration

    Swift

    public var keepAliveUntil: TimeInterval
  • A flag that indicates that there is a request in progress

    Usage Example:

    processor?.inProgress = false
    

    Declaration

    Swift

    public var inProgress: Bool
  • Process data read from the socket. It is either passed to the HTTP parser or it is saved in the Pseudo synchronous reader to be read later on.

    Usage Example:

    let processed = processor.process(readBuffer)
    

    Declaration

    Swift

    public func process(_ buffer: NSData) -> Bool

    Parameters

    buffer

    An NSData object that contains the data read from the socket.

    Return Value

    true if the data was processed, false if it needs to be processed later.

  • Write data to the socket

    Usage Example:

    processor.write(from: buffer)
    

    Declaration

    Swift

    public func write(from data: NSData)

    Parameters

    data

    An NSData object containing the bytes to be written to the socket.

  • Write a sequence of bytes in an array to the socket

    Usage Example:

    processor.write(from: utf8, length: utf8Length)
    

    Declaration

    Swift

    public func write(from bytes: UnsafeRawPointer, length: Int)

    Parameters

    from

    An UnsafeRawPointer to the sequence of bytes to be written to the socket.

    length

    The number of bytes to write to the socket.

  • Close the socket and mark this handler as no longer in progress.

    Usage Example:

    processor?.close()
    

    Declaration

    Swift

    public func close()
  • Called by the IncomingSocketHandler to tell us that the socket has been closed by the remote side.

    Usage Example:

    processor?.socketClosed()
    

    Declaration

    Swift

    public func socketClosed()