webserver-0.4.1: HTTP server library



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.

data Method Source

Methods of HTTP.

data Version Source

Versions of HTTP.




toStatus :: ByteString -> Maybe StatusSource

Converting numeric status to Status.

badStatus :: Status -> BoolSource

Returning True for 4xx and 5xx.

data Persist Source

The type for persist connection or not




type FieldValue = ByteStringSource

Field value of HTTP header.

toFieldKey :: ByteString -> FieldKeySource

Converting field key to FieldKey.

fromFieldKey :: FieldKey -> ByteStringSource

Converting FieldKey to field key.

type CT = ByteStringSource

The type for Content-Type.

textHtml :: CTSource

The value for text/html.

selectContentType :: String -> CTSource

Selecting a value of Content-Type from a file suffix.