webserver- HTTP server library

Safe HaskellSafe-Infered



HTTP library for HTTP server.



receive :: Handle -> IO (Maybe Request)Source

Receiving HTTP request from Handle. If request is broken, Nothing is returned.

respond :: Handle -> Version -> Persist -> Response -> IO ()Source

Sending HTTP response to Handle. If Keep is specified, the HTTP connection will be kept. If Close is specified, the connection will be closed. Version should be copied from Request.

data Request Source

Abstract data type of HTTP request.


reqMethod :: Request -> MethodSource

Request method

reqURI :: Request -> URISource

URI parsed from absolute URL or relative URL with the Host: field

reqVersion :: Request -> VersionSource

HTTP version

reqFields :: Request -> FieldsSource

Key-values of request header

reqBody :: Request -> Maybe ByteStringSource

Entity body if exists

reqLength :: Request -> IntegerSource

Length of entity body from Content-Length:

data Response Source

Abstract data type of HTTP response.


rspStatus :: Response -> StatusSource

Response status

makeResponse :: Status -> [(FieldKey, FieldValue)] -> ResponseSource

A function to make Response.

class Comm a Source

A class to abstract Request and Response.

data Fields Source

Abstract data type for Key-values of HTTP header.


lookupField :: Comm a => FieldKey -> a -> Maybe FieldValueSource

Looking up the HTTP field value.

lookupField' :: FieldKey -> Fields -> Maybe FieldValueSource

Looking up the HTTP field value.

insertField :: Comm a => FieldKey -> FieldValue -> a -> aSource

Inserting the HTTP field.

insertField' :: FieldKey -> FieldValue -> Fields -> FieldsSource

Inserting the HTTP field.

receiveFields :: Handle -> IO FieldsSource

Parsing HTTP header from Handle. This function is useful to parse CGI output.