webserver-0.3.0: HTTP server library

Network.Web.HTTP

Description

HTTP library for HTTP server.

Synopsis

Documentation

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.

Instances

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.

Instances

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.

Instances

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.

Constructors

HTTP10 
HTTP11 

Instances

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

Constructors

Close 
Keep 
PerUnknown 

Instances

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.