Modulevcr-0.1.0GHC2024
WebMock
- 20 types
- 1 class
- 173 values
- Packagevcr-0.1.0
- Exports194
- LanguageGHC2024
- LicenceMIT
- SourceStatus.hs
Constructors
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)))
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
HTTP 1.1
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
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)))
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.
HTTP method (flat ByteString type).
OK 200
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))))
A list of byte ranges.
This header has been obsoleted in RFC 9110.
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]
Renders a byte range into a ByteString.
renderByteRange (ByteRangeFrom 2048)"2048-"
Turns a byte range into a byte string Builder.
Renders a list of byte ranges into a ByteString.
renderByteRanges [ByteRangeFrom 2048, ByteRangeSuffix 20]"bytes=2048-,-20"
Turns a list of byte ranges into a byte string Builder.
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))))
HTTP CONNECT Method
HTTP DELETE Method
HTTP GET Method
HTTP HEAD Method
HTTP OPTIONS Method
HTTP PATCH Method
HTTP POST Method
HTTP PUT Method
HTTP TRACE Method
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.
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
Accepted 202
Bad Gateway 502
Bad Request 400
Conflict 409
Continue 100
Created 201
Expectation Failed 417
Forbidden 403
Found 302
Gateway Timeout 504
Gone 410
HTTP Version Not Supported 505
I'm a teapot 418
Internal Server Error 500
Length Required 411
Method Not Allowed 405
Create a Status from a status code and message.
Moved Permanently 301
Multiple Choices 300
Network Authentication Required 511 (RFC 6585)
No Content 204
Non-Authoritative Information 203
Not Acceptable 406
Not Found 404
Not Implemented 501
Not Modified 304
OK 200
Partial Content 206
Payment Required 402
Permanent Redirect 308
Precondition Failed 412
Precondition Required 428 (RFC 6585)
Proxy Authentication Required 407
Request Entity Too Large 413
Request Header Fields Too Large 431 (RFC 6585)
Request Timeout 408
Request-URI Too Long 414
Requested Range Not Satisfiable 416
Reset Content 205
See Other 303
Continue 100
Switching Protocols 101
Created 201
Accepted 202
Non-Authoritative Information 203
No Content 204
Reset Content 205
Partial Content 206
Multiple Choices 300
Moved Permanently 301
Found 302
See Other 303
Not Modified 304
Use Proxy 305
Temporary Redirect 307
Permanent Redirect 308
Bad Request 400
Unauthorized 401
Payment Required 402
Forbidden 403
Not Found 404
Method Not Allowed 405
Not Acceptable 406
Proxy Authentication Required 407
Request Timeout 408
Conflict 409
Gone 410
Length Required 411
Precondition Failed 412
Request Entity Too Large 413
Request-URI Too Long 414
Unsupported Media Type 415
Requested Range Not Satisfiable 416
Expectation Failed 417
I'm a teapot 418
Unprocessable Entity 422 (RFC 4918)
Precondition Required 428 (RFC 6585)
Too Many Requests 429 (RFC 6585)
Request Header Fields Too Large 431 (RFC 6585)
Internal Server Error 500
Not Implemented 501
Bad Gateway 502
Service Unavailable 503
Gateway Timeout 504
HTTP Version Not Supported 505
Network Authentication Required 511 (RFC 6585)
Client Error class
Checks if the status is in the 4XX range.
Informational class
Checks if the status is in the 1XX range.
Redirection class
Checks if the status is in the 3XX range.
Server Error class
Checks if the status is in the 5XX range.
Successful class
Checks if the status is in the 2XX range.
Switching Protocols 101
Temporary Redirect 307
Too Many Requests 429 (RFC 6585)
Unauthorized 401
Unprocessable Entity 422 (RFC 4918)
Unsupported Media Type 415
Use Proxy 305
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.
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.
Like Query, but with Text instead of ByteString (UTF8-encoded).
A sequence of SimpleQueryItems.
Simplified query item type without support for parameter-less items.
Decode a whole path (path segments + query).
Parse a list of path segments from a valid URL fragment.
Will also decode any percent-encoded characters.
Encode a whole path (path segments + query).
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.
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"
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.
Parse a QueryText from a ByteString. See parseQuery for details.
queryToQueryText . parseQueryParse SimpleQuery from a ByteString.
This uses parseQuery under the hood, and will transform any Nothing values into an empty ByteString.
Renders the given Query into a ByteString.
If you want a question mark (?) added to the front of the result, use True.
Convert a PartialEscapeQuery to a Builder.
If you want a question mark (?) added to the front of the result, use True.
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"
Render the given SimpleQuery into a ByteString.
If you want a question mark (?) added to the front of the result, use True.
Convert SimpleQuery to Query.
Percent-decoding.
If you want to replace any '+' with a space, use True.
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','
HTTP 0.9
HTTP 1.0
HTTP 2.0