Network.HTTP.Types
Contents
- type Method = Ascii
- methodGet :: Method
- methodPost :: Method
- methodHead :: Method
- methodPut :: Method
- methodDelete :: Method
- methodTrace :: Method
- methodConnect :: Method
- methodOptions :: Method
- data StdMethod
- parseMethod :: Method -> Either Ascii StdMethod
- renderMethod :: Either Ascii StdMethod -> Method
- renderStdMethod :: StdMethod -> Method
- data HttpVersion = HttpVersion {}
- http09 :: HttpVersion
- http10 :: HttpVersion
- http11 :: HttpVersion
- data Status = Status {
- statusCode :: Int
- statusMessage :: Ascii
- status200 :: Status
- statusOK :: Status
- status201 :: Status
- statusCreated :: Status
- status206 :: Status
- statusPartialContent :: Status
- status301 :: Status
- statusMovedPermanently :: Status
- status302 :: Status
- statusFound :: Status
- status303 :: Status
- statusSeeOther :: Status
- status400 :: Status
- statusBadRequest :: Status
- status401 :: Status
- statusUnauthorized :: Status
- status403 :: Status
- statusForbidden :: Status
- status404 :: Status
- statusNotFound :: Status
- status405 :: Status
- statusNotAllowed :: Status
- status500 :: Status
- statusServerError :: Status
- type Header = (CIAscii, Ascii)
- type RequestHeaders = [Header]
- type ResponseHeaders = [Header]
- headerAccept :: Ascii -> Header
- headerCacheControl :: Ascii -> Header
- headerConnection :: Ascii -> Header
- headerContentLength :: Ascii -> Header
- headerContentType :: Ascii -> Header
- headerContentMD5 :: Ascii -> Header
- headerDate :: Ascii -> Header
- type QueryItem = (ByteString, Maybe ByteString)
- type Query = [QueryItem]
- type SimpleQueryItem = (ByteString, ByteString)
- type SimpleQuery = [SimpleQueryItem]
- simpleQueryToQuery :: SimpleQuery -> Query
- renderQuery :: Bool -> Query -> Ascii
- renderQueryBuilder :: Bool -> Query -> AsciiBuilder
- renderSimpleQuery :: Bool -> SimpleQuery -> Ascii
- parseQuery :: ByteString -> Query
- parseSimpleQuery :: ByteString -> SimpleQuery
- type QueryText = [(Text, Maybe Text)]
- queryTextToQuery :: QueryText -> Query
- queryToQueryText :: Query -> QueryText
- renderQueryText :: Bool -> QueryText -> AsciiBuilder
- parseQueryText :: ByteString -> QueryText
- encodePathSegments :: [Text] -> AsciiBuilder
- decodePathSegments :: ByteString -> [Text]
- encodePath :: [Text] -> Query -> AsciiBuilder
- decodePath :: ByteString -> ([Text], Query)
- urlEncodeBuilder :: Bool -> ByteString -> AsciiBuilder
- urlEncode :: Bool -> ByteString -> Ascii
- urlDecode :: Bool -> ByteString -> ByteString
Methods
HTTP Method constants.
HTTP standard method (as defined by RFC 2616).
parseMethod :: Method -> Either Ascii StdMethodSource
Convert a method ByteString
to a StdMethod
if possible.
renderStdMethod :: StdMethod -> MethodSource
Convert a StdMethod
to a ByteString
.
Versions
data HttpVersion Source
HTTP Version.
Note that the Show instance is intended merely for debugging.
Constructors
HttpVersion | |
Instances
HTTP 0.9
HTTP 1.0
HTTP 1.1
Status
HTTP Status.
Only the statusCode
is used for comparisons.
Note that the Show instance is only for debugging.
Constructors
Status | |
Fields
|
Created
statusPartialContent :: StatusSource
PartialContent
statusMovedPermanently :: StatusSource
Moved Permanently
Found
statusSeeOther :: StatusSource
See Other
statusBadRequest :: StatusSource
Bad Request
statusUnauthorized :: StatusSource
Unauthorized
statusForbidden :: StatusSource
Forbidden
statusNotFound :: StatusSource
Not Found
statusNotAllowed :: StatusSource
Method Not Allowed
statusServerError :: StatusSource
Internal Server Error
Headers
type RequestHeaders = [Header]Source
Request Headers
type ResponseHeaders = [Header]Source
Response Headers
headerAccept :: Ascii -> HeaderSource
headerCacheControl :: Ascii -> HeaderSource
HTTP Headers
headerDate :: Ascii -> HeaderSource
Query string
type QueryItem = (ByteString, Maybe ByteString)Source
Query item
type Query = [QueryItem]Source
Query.
General form: a=b&c=d, but if the value is Nothing, it becomes a&c=d.
type SimpleQueryItem = (ByteString, ByteString)Source
Simplified Query item type without support for parameter-less items.
type SimpleQuery = [SimpleQueryItem]Source
Simplified Query type without support for parameter-less items.
simpleQueryToQuery :: SimpleQuery -> QuerySource
Convert SimpleQuery
to Query
.
Convert Query
to ByteString
.
Arguments
:: Bool | prepend a question mark? |
-> Query | |
-> AsciiBuilder |
Arguments
:: Bool | prepend question mark? |
-> SimpleQuery | |
-> Ascii |
Convert SimpleQuery
to ByteString
.
parseQuery :: ByteString -> QuerySource
Split out the query string into a list of keys and values. A few importants points:
parseSimpleQuery :: ByteString -> SimpleQuerySource
Parse SimpleQuery
from a ByteString
.
Text query string (UTF8 encoded)
Arguments
:: Bool | prepend a question mark? |
-> QueryText | |
-> AsciiBuilder |
Path segments
encodePathSegments :: [Text] -> AsciiBuilderSource
Encodes a list of path segments into a valid URL fragment.
This function takes the following three steps:
- UTF-8 encodes the characters.
- Performs percent encoding on all unreserved characters, as well as :@=+$,
- Intercalates with a slash.
For example:
encodePathInfo [\"foo\", \"bar\", \"baz\"]
"foo/bar/baz"
encodePathInfo [\"foo bar\", \"baz\/bin\"]
"foo%20bar/baz%2Fbin"
encodePathInfo [\"\"]
"%D7%A9%D7%9C%D7%95%D7%9D"
Huge thanks to Jeremy Shaw who created the original implementation of this function in web-routes and did such thorough research to determine all correct escaping procedures.
decodePathSegments :: ByteString -> [Text]Source
Path (segments + query string)
encodePath :: [Text] -> Query -> AsciiBuilderSource
decodePath :: ByteString -> ([Text], Query)Source
URL encoding / decoding
Arguments
:: Bool | Whether input is in query string. True: Query string, False: Path element |
-> ByteString | |
-> AsciiBuilder |
urlEncode :: Bool -> ByteString -> AsciiSource
Arguments
:: Bool | Whether to decode |
-> ByteString | |
-> ByteString |
Percent-decoding.