webserver-0.7.1.0: HTTP server library

Safe HaskellSafe-Inferred

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.