HTTP method (flat ByteString type).
Modulehttp-types-0.12.4Haskell2010
Network.HTTP.Types
- 18 types
- 1 class
- 162 values
- Packagehttp-types-0.12.4
- Exports181
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceMethod.hs
Methods
1 declarationFor more information: Network.HTTP.Types.Method
Constants
HTTP GET Method
HTTP POST Method
HTTP HEAD Method
HTTP PUT Method
HTTP DELETE Method
HTTP TRACE Method
HTTP CONNECT Method
HTTP OPTIONS Method
HTTP PATCH Method
HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).
Instances10Bounded, Enum, Eq, Data, Ord, Read, …
Bounded StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.MethodEnum StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.MethodEq StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.MethodData StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.MethodOrd StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.MethodRead StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.MethodShow StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.MethodIx StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.MethodGeneric StdMethodDefined in http-types-0.12.4 · Network.HTTP.Types.Methodtype Rep StdMethod = D1 ('MetaDataDefined in http-types-0.12.4 · Network.HTTP.Types.Method"StdMethod"
"Network.HTTP.Types.Method"
"http-types-0.12.4-KkMxTblWZY5WJ4M2x8W7s"
'False) (((C1 ('MetaCons"GET"
'PrefixI 'False) U1 :+: C1 ('MetaCons"POST"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"HEAD"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PUT"
'PrefixI 'False) U1)) :+: ((C1 ('MetaCons"DELETE"
'PrefixI 'False) U1 :+: C1 ('MetaCons"TRACE"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"CONNECT"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"OPTIONS"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PATCH"
'PrefixI 'False) U1))))
Parsing and redering methods
Convert a method ByteString to a StdMethod if possible.
Convert an algebraic method to a ByteString.
renderMethod (parseMethod bs) == bsConvert a StdMethod to a ByteString.
Versions
5 declarationsFor more information: Network.HTTP.Types.Version
HTTP Version.
Note that the Show instance is intended merely for debugging.
Constructors
Instances6Eq, Data, Ord, Show, Generic, Rep
Eq HttpVersionDefined in http-types-0.12.4 · Network.HTTP.Types.VersionData HttpVersionDefined in http-types-0.12.4 · Network.HTTP.Types.VersionOrd HttpVersionDefined in http-types-0.12.4 · Network.HTTP.Types.VersionShow HttpVersionDefined in http-types-0.12.4 · Network.HTTP.Types.VersionExample1 expression show http11"HTTP/1.1"
Generic HttpVersionDefined in http-types-0.12.4 · Network.HTTP.Types.Versiontype Rep HttpVersion = D1 ('MetaDataDefined in http-types-0.12.4 · Network.HTTP.Types.Version"HttpVersion"
"Network.HTTP.Types.Version"
"http-types-0.12.4-KkMxTblWZY5WJ4M2x8W7s"
'False) (C1 ('MetaCons"HttpVersion"
'PrefixI 'True) (S1 ('MetaSel ('Just"httpMajor"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Int) :*: S1 ('MetaSel ('Just"httpMinor"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Int)))
HTTP 0.9
HTTP 1.0
HTTP 1.1
HTTP 2.0
Status
1 declarationFor more information: Network.HTTP.Types.Status
HTTP Status.
Only the statusCode is used for comparisons.
Please use mkStatus to create status codes from code and message, or the Enum instance or the status code constants (like ok200). There might be additional record members in the future.
Note that the Show instance is only for debugging.
Constructors
Instances8Bounded, Enum, Eq, Data, Ord, Show, …
Bounded StatusDefined in http-types-0.12.4 · Network.HTTP.Types.StatusEnum StatusDefined in http-types-0.12.4 · Network.HTTP.Types.StatusBe advised, that when using the "enumFrom*" family of methods or ranges in lists, it will generate all possible status codes.
E.g.
[status100 .. status200]generates Statuses of100, 101, 102 .. 198, 199, 200The statuses not included in this library will have an empty message.
Eq StatusDefined in http-types-0.12.4 · Network.HTTP.Types.StatusData StatusDefined in http-types-0.12.4 · Network.HTTP.Types.StatusOrd StatusDefined in http-types-0.12.4 · Network.HTTP.Types.StatusStatuses are ordered according to their status codes only.
Show StatusDefined in http-types-0.12.4 · Network.HTTP.Types.StatusGeneric StatusDefined in http-types-0.12.4 · Network.HTTP.Types.Statustype Rep Status = D1 ('MetaDataDefined in http-types-0.12.4 · Network.HTTP.Types.Status"Status"
"Network.HTTP.Types.Status"
"http-types-0.12.4-KkMxTblWZY5WJ4M2x8W7s"
'False) (C1 ('MetaCons"Status"
'PrefixI 'True) (S1 ('MetaSel ('Just"statusCode"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just"statusMessage"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))
Constants
Create a Status from a status code and message.
Continue 100
Continue 100
Switching Protocols 101
Switching Protocols 101
OK 200
OK 200
Created 201
Created 201
Accepted 202
Accepted 202
Non-Authoritative Information 203
Non-Authoritative Information 203
No Content 204
No Content 204
Reset Content 205
Reset Content 205
Partial Content 206
Partial Content 206
Multiple Choices 300
Multiple Choices 300
Moved Permanently 301
Moved Permanently 301
Found 302
Found 302
See Other 303
See Other 303
Not Modified 304
Not Modified 304
Use Proxy 305
Use Proxy 305
Temporary Redirect 307
Temporary Redirect 307
Permanent Redirect 308
Permanent Redirect 308
Bad Request 400
Bad Request 400
Unauthorized 401
Unauthorized 401
Payment Required 402
Payment Required 402
Forbidden 403
Forbidden 403
Not Found 404
Not Found 404
Method Not Allowed 405
Method Not Allowed 405
Not Acceptable 406
Not Acceptable 406
Proxy Authentication Required 407
Proxy Authentication Required 407
Request Timeout 408
Request Timeout 408
Conflict 409
Conflict 409
Gone 410
Gone 410
Length Required 411
Length Required 411
Precondition Failed 412
Precondition Failed 412
Request Entity Too Large 413
Request Entity Too Large 413
Request-URI Too Long 414
Request-URI Too Long 414
Unsupported Media Type 415
Unsupported Media Type 415
Requested Range Not Satisfiable 416
Requested Range Not Satisfiable 416
Expectation Failed 417
Expectation Failed 417
I'm a teapot 418
I'm a teapot 418
Unprocessable Entity 422 (RFC 4918)
Unprocessable Entity 422 (RFC 4918)
Precondition Required 428 (RFC 6585)
Precondition Required 428 (RFC 6585)
Too Many Requests 429 (RFC 6585)
Too Many Requests 429 (RFC 6585)
Request Header Fields Too Large 431 (RFC 6585)
Request Header Fields Too Large 431 (RFC 6585)
Internal Server Error 500
Internal Server Error 500
Not Implemented 501
Not Implemented 501
Bad Gateway 502
Bad Gateway 502
Service Unavailable 503
Gateway Timeout 504
Gateway Timeout 504
HTTP Version Not Supported 505
HTTP Version Not Supported 505
Network Authentication Required 511 (RFC 6585)
Network Authentication Required 511 (RFC 6585)
Informational class
Checks if the status is in the 1XX range.
Successful class
Checks if the status is in the 2XX range.
Redirection class
Checks if the status is in the 3XX range.
Client Error class
Checks if the status is in the 4XX range.
Server Error class
Checks if the status is in the 5XX range.
Headers
0 declarationsFor more information: Network.HTTP.Types.Header
Types
A full HTTP header field with the name and value separated.
E.g. "Content-Length: 28" parsed into a Header would turn into ("Content-Length", "28")
A case-insensitive name of a header field.
This is the part of the header field before the colon: HeaderName: some value
A list of Headers.
Same type as ResponseHeaders, but useful to differentiate in type signatures.
A list of Headers.
Same type as RequestHeaders, but useful to differentiate in type signatures.
Common headers
This header has been obsoleted in RFC 9110.
Byte ranges
An individual byte range.
Negative indices are not allowed!
Constructors
Instances6Eq, Data, Ord, Show, Generic, Rep
Eq ByteRangeDefined in http-types-0.12.4 · Network.HTTP.Types.HeaderData ByteRangeDefined in http-types-0.12.4 · Network.HTTP.Types.HeaderOrd ByteRangeDefined in http-types-0.12.4 · Network.HTTP.Types.HeaderShow ByteRangeDefined in http-types-0.12.4 · Network.HTTP.Types.HeaderGeneric ByteRangeDefined in http-types-0.12.4 · Network.HTTP.Types.Headertype Rep ByteRange = D1 ('MetaDataDefined in http-types-0.12.4 · Network.HTTP.Types.Header"ByteRange"
"Network.HTTP.Types.Header"
"http-types-0.12.4-KkMxTblWZY5WJ4M2x8W7s"
'False) (C1 ('MetaCons"ByteRangeFrom"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer)) :+: (C1 ('MetaCons"ByteRangeFromTo"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer)) :+: C1 ('MetaCons"ByteRangeSuffix"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer))))
Turns a byte range into a byte string Builder.
Renders a byte range into a ByteString.
renderByteRange (ByteRangeFrom 2048)"2048-"
A list of byte ranges.
Turns a list of byte ranges into a byte string Builder.
Renders a list of byte ranges into a ByteString.
renderByteRanges [ByteRangeFrom 2048, ByteRangeSuffix 20]"bytes=2048-,-20"
Parse the value of a Range header into a ByteRanges.
parseByteRanges "error"NothingparseByteRanges "bytes=0-499"Just [ByteRangeFromTo 0 499]parseByteRanges "bytes=500-999"Just [ByteRangeFromTo 500 999]parseByteRanges "bytes=-500"Just [ByteRangeSuffix 500]parseByteRanges "bytes=9500-"Just [ByteRangeFrom 9500]parseByteRanges "bytes=0-0,-1"Just [ByteRangeFromTo 0 0,ByteRangeSuffix 1]parseByteRanges "bytes=500-600,601-999"Just [ByteRangeFromTo 500 600,ByteRangeFromTo 601 999]parseByteRanges "bytes=500-700,601-999"Just [ByteRangeFromTo 500 700,ByteRangeFromTo 601 999]
URI
0 declarationsFor more extensive information: Network.HTTP.Types.URI
Query strings
Query
A sequence of QueryItems.
An item from the query string, split up into two parts.
The second part should be Nothing if there was no key-value separator after the query item name.
Renders the given Query into a ByteString.
If you want a question mark (?) added to the front of the result, use True.
Split out the query string into a list of keys and values. A few importants points:
The result returned is still bytestrings, since we perform no character decoding here. Most likely, you will want to use UTF-8 decoding, but this is left to the user of the library.
Percent decoding errors are ignored. In particular,
"%Q"will be output as"%Q".It decodes
'+'characters to' '
Same functionality as parseQuery, but with the option to decode '+' characters to ' '
or to preserve any '+' encountered.
If you want to replace any '+' with a space, use True.
Text query string (UTF8 encoded)
Like Query, but with Text instead of ByteString (UTF8-encoded).
Parse a QueryText from a ByteString. See parseQuery for details.
queryToQueryText . parseQuerySimpleQuery
A sequence of SimpleQueryItems.
Simplified query item type without support for parameter-less items.
Convert SimpleQuery to Query.
Render the given SimpleQuery into a ByteString.
If you want a question mark (?) added to the front of the result, use True.
Parse SimpleQuery from a ByteString.
This uses parseQuery under the hood, and will transform any Nothing values into an empty ByteString.
PartialEscapeQuery
Query with some characters that should not be escaped.
General form: a=b&c=d:e+f&g=h
Partially escaped query item.
The key will always be encoded using 'urlEncode True',
but the value will be encoded depending on which EscapeItems are used.
Section of a query item value that decides whether to use
regular URL encoding (using 'urlEncode True') with QE,
or to not encode anything with QN.
Constructors
QE ByteStringwill be URL encoded
QN ByteStringwill NOT at all be URL encoded
Instances3Eq, Ord, Show
Eq EscapeItemDefined in http-types-0.12.4 · Network.HTTP.Types.URIOrd EscapeItemDefined in http-types-0.12.4 · Network.HTTP.Types.URIShow EscapeItemDefined in http-types-0.12.4 · Network.HTTP.Types.URI
Convert PartialEscapeQuery to ByteString.
If you want a question mark (?) added to the front of the result, use True.
renderQueryPartialEscape True [("a", [QN "x:z + ", QE (encodeUtf8 "They said: \"שלום\"")])]"?a=x:z + They%20said%3A%20%22%D7%A9%D7%9C%D7%95%D7%9D%22"
Convert a PartialEscapeQuery to a Builder.
If you want a question mark (?) added to the front of the result, use True.
Generalized query types
Types which can, and commonly are, converted to Query are in this class.
You can use lists of simple key value pairs, with ByteString (strict, or lazy: ByteString), Text, or String as the key/value types. You can also have the value type lifted into a Maybe to support keys without values; and finally it is possible to put each pair into a Maybe for key-value pairs that aren't always present.
Instances2QueryLike
(QueryKeyLike k, QueryValueLike v) => QueryLike [Maybe (k, v)]Defined in http-types-0.12.4 · Network.HTTP.Types.QueryLike(QueryKeyLike k, QueryValueLike v) => QueryLike [(k, v)]Defined in http-types-0.12.4 · Network.HTTP.Types.QueryLike
Path
Segments + Query String
Extract whole path (path segments + query) from a RFC 2616 Request-URI.
Though a more accurate description of this function's behaviour is that
it removes the domain/origin if the string starts with an HTTP protocol.
(i.e. http:// or https://)
This function will not change anything when given any other ByteString.
(except return a root path "/" if given an empty string)
extractPath "/path""/path"
extractPath "http://example.com:8080/path""/path"
extractPath "http://example.com""/"
extractPath """/"
extractPath "www.google.com/some/path""www.google.com/some/path"
Encode a whole path (path segments + query).
Decode a whole path (path segments + query).
Path Segments
Encodes a list of path segments into a valid URL fragment.
This function takes the following three steps:
UTF-8 encodes the characters.
Prepends each segment with a slash.
Performs percent-encoding on all characters that are not:
alphanumeric (i.e.
A-Zanda-z)digits (i.e.
0-9)a dash
'-', an underscore'_', a dot'.', or a tilde'~'
For example:
encodePathSegments ["foo", "bar1", "~baz"]"/foo/bar1/~baz"
encodePathSegments ["foo bar", "baz/bin"]"/foo%20bar/baz%2Fbin"
encodePathSegments ["שלום"]"/%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.
Like encodePathSegments, but without the initial slash.
Parse a list of path segments from a valid URL fragment.
Will also decode any percent-encoded characters.
URL encoding / decoding
Percent-encoding for URLs.
In short:
if you're encoding (parts of) a path element, use False.
if you're encoding (parts of) a query string, use True.
In-depth explanation
This will substitute every byte with its percent-encoded equivalent unless:
The byte is alphanumeric. (i.e.
A-Z,a-z, or0-9)The byte is either a dash
'-', an underscore'_', a dot'.', or a tilde'~'If False is used, the following will also not be percent-encoded:
colon
':', at sign'@', ampersand'&', equals sign'=', plus sign'+', dollar sign'$'or a comma','
Percent-decoding.
If you want to replace any '+' with a space, use True.