Network.Protocol.Http
Contents
- data Method
- data Version
- type Key = String
- type Value = String
- newtype Headers = Headers {}
- data Request = Request Method String
- data Response = Response Status
- data Http a = Http a Version Headers
- http10 :: Version
- http11 :: Version
- emptyHeaders :: Headers
- emptyRequest :: Http Request
- emptyResponse :: Http Response
- methods :: [Method]
- major :: Version :-> Int
- minor :: Version :-> Int
- headers :: Http a :-> Headers
- version :: Http a :-> Version
- headline :: Http a :-> a
- method :: Http Request :-> Method
- uri :: Http Request :-> String
- asUri :: Http Request :-> Uri
- status :: Http Response :-> Status
- normalizeHeader :: Key -> Key
- header :: Key -> Http a :-> Maybe Value
- contentLength :: (Read i, Integral i) => Http a :-> Maybe i
- connection :: Http a :-> Maybe String
- accept :: Http a :-> Maybe Parameters
- acceptEncoding :: Http a :-> Maybe [String]
- acceptLanguage :: Http a :-> Maybe [String]
- cacheControl :: Http a :-> Maybe String
- keepAlive :: (Read i, Integral i) => Http a :-> Maybe i
- cookie :: Http Request :-> Maybe String
- setCookie :: Http Response :-> Maybe String
- location :: Http a :-> Maybe String
- contentType :: Http a :-> Maybe (String, Maybe String)
- date :: Http a :-> Maybe String
- hostname :: Http a :-> Maybe String
- server :: Http a :-> Maybe String
- userAgent :: Http a :-> Maybe String
- upgrade :: Http a :-> Maybe String
- lastModified :: Http a :-> Maybe Value
- acceptRanges :: Http a :-> Maybe Value
- eTag :: Http a :-> Maybe Value
- parseRequest :: String -> Either String (Http Request)
- parseResponse :: String -> Either String (Http Response)
- parseHeaders :: String -> Either String Headers
- pRequest :: GenParser Char st (Http Request)
- pResponse :: GenParser Char st (Http Response)
- pHeaders :: GenParser Char st Headers
- pVersion :: GenParser Char st Version
- pMethod :: GenParser Char st Method
- versionFromString :: String -> Version
- methodFromString :: String -> Method
- showRequestLine :: Http Request -> String -> String
- showResponseLine :: Http Response -> String -> String
- data Status
- = Continue
- | SwitchingProtocols
- | OK
- | Created
- | Accepted
- | NonAuthoritativeInformation
- | NoContent
- | ResetContent
- | PartialContent
- | MultipleChoices
- | MovedPermanently
- | Found
- | SeeOther
- | NotModified
- | UseProxy
- | TemporaryRedirect
- | BadRequest
- | Unauthorized
- | PaymentRequired
- | Forbidden
- | NotFound
- | MethodNotAllowed
- | NotAcceptable
- | ProxyAuthenticationRequired
- | RequestTimeOut
- | Conflict
- | Gone
- | LengthRequired
- | PreconditionFailed
- | RequestEntityTooLarge
- | RequestURITooLarge
- | UnsupportedMediaType
- | RequestedRangeNotSatisfiable
- | ExpectationFailed
- | InternalServerError
- | NotImplemented
- | BadGateway
- | ServiceUnavailable
- | GatewayTimeOut
- | HTTPVersionNotSupported
- | CustomStatus Int String
- statusFailure :: Status -> Bool
- statusFromCode :: Int -> Status
- codeFromStatus :: Status -> Int
HTTP message data types.
List of HTTP request methods.
HTTP headers as mapping from keys to values.
Request specific part of HTTP messages.
Response specific part of HTTP messages.
An HTTP message. The message body is *not* included.
Creating (parts of) messages.
Create an empty set of headers.
emptyRequest :: Http RequestSource
Create an empty HTTP request message.
emptyResponse :: Http ResponseSource
Create an empty HTTP response message.
Accessing fields.
asUri :: Http Request :-> UriSource
Label to access the URI part of an HTTP request message and access it as a true URI data type.
status :: Http Response :-> StatusSource
Label to access the status part of an HTTP response message.
normalizeHeader :: Key -> KeySource
Normalize the capitalization of an HTTP header key.
Accessing specific header fields.
contentLength :: (Read i, Integral i) => Http a :-> Maybe iSource
Access the Content-Length header field.
contentType :: Http a :-> Maybe (String, Maybe String)Source
Access the Content-Type header field. The content-type will be parsed into a mimetype and optional charset.
Parsing HTTP messages.
parseRequest :: String -> Either String (Http Request)Source
Parse a string as an HTTP request message. This parser is very forgiving.
parseResponse :: String -> Either String (Http Response)Source
Parse a string as an HTTP request message. This parser is very forgiving.
Exposure of internal parsec parsers.
pRequest :: GenParser Char st (Http Request)Source
Parsec parser to parse the header part of an HTTP request.
pResponse :: GenParser Char st (Http Response)Source
Parsec parser to parse the header part of an HTTP response.
pHeaders :: GenParser Char st HeadersSource
Parsec parser to parse one or more, possibly multiline, HTTP header lines.
pVersion :: GenParser Char st VersionSource
Parsec parser to parse HTTP versions. Recognizes X.X versions only.
pMethod :: GenParser Char st MethodSource
Parsec parser to parse an HTTP method. Parses arbitrary method but
actually recognizes the ones listed as a constructor for Method
.
Parser helper methods.
versionFromString :: String -> VersionSource
Recognizes HTTP protocol version 1.0 and 1.1, all other string will produce version 1.1.
methodFromString :: String -> MethodSource
Helper to turn fully capitalized string into request method.
Printer helper methods.
Handling HTTP status codes.
HTTP status codes.
Constructors
Continue | 100 |
SwitchingProtocols | 101 |
OK | 200 |
Created | 201 |
Accepted | 202 |
NonAuthoritativeInformation | 203 |
NoContent | 204 |
ResetContent | 205 |
PartialContent | 206 |
MultipleChoices | 300 |
MovedPermanently | 301 |
Found | 302 |
SeeOther | 303 |
NotModified | 304 |
UseProxy | 305 |
TemporaryRedirect | 307 |
BadRequest | 400 |
Unauthorized | 401 |
PaymentRequired | 402 |
Forbidden | 403 |
NotFound | 404 |
MethodNotAllowed | 405 |
NotAcceptable | 406 |
ProxyAuthenticationRequired | 407 |
RequestTimeOut | 408 |
Conflict | 409 |
Gone | 410 |
LengthRequired | 411 |
PreconditionFailed | 412 |
RequestEntityTooLarge | 413 |
RequestURITooLarge | 414 |
UnsupportedMediaType | 415 |
RequestedRangeNotSatisfiable | 416 |
ExpectationFailed | 417 |
InternalServerError | 500 |
NotImplemented | 501 |
BadGateway | 502 |
ServiceUnavailable | 503 |
GatewayTimeOut | 504 |
HTTPVersionNotSupported | 505 |
CustomStatus Int String |
statusFailure :: Status -> BoolSource
Every status greater-than or equal to 400 is considered to be a failure.
statusFromCode :: Int -> StatusSource
Conversion from status numbers to codes.
codeFromStatus :: Status -> IntSource
Conversion from status codes to numbers.