-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generic HTTP types for Haskell (for both client and server code). -- -- Types and functions to describe and handle HTTP concepts. Including -- "methods", "headers", "query strings", "paths" and "HTTP versions". @package http-types @version 0.12.4 -- | Type and constants for handling HTTP header fields. -- -- At the bottom are also some functions to handle certain header field -- values. module Network.HTTP.Types.Header -- | 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") type Header = (HeaderName, ByteString) -- | A case-insensitive name of a header field. -- -- This is the part of the header field before the colon: HeaderName: -- some value type HeaderName = CI ByteString -- | A list of Headers. -- -- Same type as ResponseHeaders, but useful to differentiate in -- type signatures. type RequestHeaders = [Header] -- | A list of Headers. -- -- Same type as RequestHeaders, but useful to differentiate in -- type signatures. type ResponseHeaders = [Header] -- | Accept hAccept :: HeaderName -- | Accept-Charset hAcceptCharset :: HeaderName -- | Accept-Encoding hAcceptEncoding :: HeaderName -- | Accept-Language hAcceptLanguage :: HeaderName -- | Accept-Ranges hAcceptRanges :: HeaderName -- | Age hAge :: HeaderName -- | Allow hAllow :: HeaderName -- | Authorization hAuthorization :: HeaderName -- | Cache-Control hCacheControl :: HeaderName -- | Connection hConnection :: HeaderName -- | Content-Disposition hContentDisposition :: HeaderName -- | Content-Encoding hContentEncoding :: HeaderName -- | Content-Language hContentLanguage :: HeaderName -- | Content-Length hContentLength :: HeaderName -- | Content-Location hContentLocation :: HeaderName -- | Content-MD5 -- -- This header has been obsoleted in RFC 9110. hContentMD5 :: HeaderName -- | Content-Range hContentRange :: HeaderName -- | Content-Type hContentType :: HeaderName -- | Cookie hCookie :: HeaderName -- | Date hDate :: HeaderName -- | ETag hETag :: HeaderName -- | Expect hExpect :: HeaderName -- | Expires hExpires :: HeaderName -- | From hFrom :: HeaderName -- | Host hHost :: HeaderName -- | If-Match hIfMatch :: HeaderName -- | If-Modified-Since hIfModifiedSince :: HeaderName -- | If-None-Match hIfNoneMatch :: HeaderName -- | If-Range hIfRange :: HeaderName -- | If-Unmodified-Since hIfUnmodifiedSince :: HeaderName -- | Last-Modified hLastModified :: HeaderName -- | Location hLocation :: HeaderName -- | Max-Forwards hMaxForwards :: HeaderName -- | MIME-Version hMIMEVersion :: HeaderName -- | Origin hOrigin :: HeaderName -- | Pragma -- -- This header has been deprecated in RFC 9111 in favor of -- "Cache-Control". hPragma :: HeaderName -- | Prefer hPrefer :: HeaderName -- | Preference-Applied hPreferenceApplied :: HeaderName -- | Proxy-Authenticate hProxyAuthenticate :: HeaderName -- | Proxy-Authorization hProxyAuthorization :: HeaderName -- | Range hRange :: HeaderName -- | Referer hReferer :: HeaderName -- | Retry-After hRetryAfter :: HeaderName -- | Server hServer :: HeaderName -- | Set-Cookie hSetCookie :: HeaderName -- | TE hTE :: HeaderName -- | Trailer hTrailer :: HeaderName -- | Transfer-Encoding hTransferEncoding :: HeaderName -- | Upgrade hUpgrade :: HeaderName -- | User-Agent hUserAgent :: HeaderName -- | Vary hVary :: HeaderName -- | Via hVia :: HeaderName -- | WWW-Authenticate hWWWAuthenticate :: HeaderName -- | Warning -- -- This header has been obsoleted in RFC 9110. hWarning :: HeaderName -- | An individual byte range. -- -- Negative indices are not allowed! data ByteRange ByteRangeFrom :: !Integer -> ByteRange ByteRangeFromTo :: !Integer -> !Integer -> ByteRange ByteRangeSuffix :: !Integer -> ByteRange -- | Turns a byte range into a byte string Builder. renderByteRangeBuilder :: ByteRange -> Builder -- | Renders a byte range into a ByteString. -- --
--   >>> renderByteRange (ByteRangeFrom 2048)
--   "2048-"
--   
renderByteRange :: ByteRange -> ByteString -- | A list of byte ranges. type ByteRanges = [ByteRange] -- | Turns a list of byte ranges into a byte string Builder. renderByteRangesBuilder :: ByteRanges -> Builder -- | Renders a list of byte ranges into a ByteString. -- --
--   >>> renderByteRanges [ByteRangeFrom 2048, ByteRangeSuffix 20]
--   "bytes=2048-,-20"
--   
renderByteRanges :: ByteRanges -> ByteString -- | Parse the value of a Range header into a ByteRanges. -- --
--   >>> parseByteRanges "error"
--   Nothing
--   
--   >>> parseByteRanges "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]
--   
parseByteRanges :: ByteString -> Maybe ByteRanges instance GHC.Generics.Generic Network.HTTP.Types.Header.ByteRange instance Data.Data.Data Network.HTTP.Types.Header.ByteRange instance GHC.Classes.Ord Network.HTTP.Types.Header.ByteRange instance GHC.Classes.Eq Network.HTTP.Types.Header.ByteRange instance GHC.Show.Show Network.HTTP.Types.Header.ByteRange -- | Types and constants for HTTP methods. -- -- The HTTP standard defines a set of standard methods, when to use them, -- and how to handle them. The standard set has been provided as a -- separate data type StdMethod, but since you can also use custom -- methods, the basic type Method is just a synonym for -- ByteString. module Network.HTTP.Types.Method -- | HTTP method (flat ByteString type). type Method = ByteString -- | HTTP GET Method methodGet :: Method -- | HTTP POST Method methodPost :: Method -- | HTTP HEAD Method methodHead :: Method -- | HTTP PUT Method methodPut :: Method -- | HTTP DELETE Method methodDelete :: Method -- | HTTP TRACE Method methodTrace :: Method -- | HTTP CONNECT Method methodConnect :: Method -- | HTTP OPTIONS Method methodOptions :: Method -- | HTTP PATCH Method methodPatch :: Method -- | HTTP standard method (as defined by RFC 2616, and PATCH which is -- defined by RFC 5789). data StdMethod GET :: StdMethod POST :: StdMethod HEAD :: StdMethod PUT :: StdMethod DELETE :: StdMethod TRACE :: StdMethod CONNECT :: StdMethod OPTIONS :: StdMethod PATCH :: StdMethod -- | Convert a method ByteString to a StdMethod if -- possible. parseMethod :: Method -> Either ByteString StdMethod -- | Convert an algebraic method to a ByteString. -- --
--   renderMethod (parseMethod bs) == bs
--   
renderMethod :: Either ByteString StdMethod -> Method -- | Convert a StdMethod to a ByteString. renderStdMethod :: StdMethod -> Method instance Data.Data.Data Network.HTTP.Types.Method.StdMethod instance GHC.Generics.Generic Network.HTTP.Types.Method.StdMethod instance GHC.Ix.Ix Network.HTTP.Types.Method.StdMethod instance GHC.Enum.Bounded Network.HTTP.Types.Method.StdMethod instance GHC.Enum.Enum Network.HTTP.Types.Method.StdMethod instance GHC.Classes.Ord Network.HTTP.Types.Method.StdMethod instance GHC.Classes.Eq Network.HTTP.Types.Method.StdMethod instance GHC.Show.Show Network.HTTP.Types.Method.StdMethod instance GHC.Read.Read Network.HTTP.Types.Method.StdMethod -- | Types and constants to describe HTTP status codes. -- -- At the bottom are some functions to check if a given Status is -- from a certain category. (i.e. 1XX, 2XX, etc.) module 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. data Status Status :: Int -> ByteString -> Status statusCode :: Status -> Int statusMessage :: Status -> ByteString -- | Create a Status from a status code and message. mkStatus :: Int -> ByteString -> Status -- | Continue 100 status100 :: Status -- | Continue 100 continue100 :: Status -- | Switching Protocols 101 status101 :: Status -- | Switching Protocols 101 switchingProtocols101 :: Status -- | OK 200 status200 :: Status -- | OK 200 ok200 :: Status -- | Created 201 status201 :: Status -- | Created 201 created201 :: Status -- | Accepted 202 status202 :: Status -- | Accepted 202 accepted202 :: Status -- | Non-Authoritative Information 203 status203 :: Status -- | Non-Authoritative Information 203 nonAuthoritative203 :: Status -- | No Content 204 status204 :: Status -- | No Content 204 noContent204 :: Status -- | Reset Content 205 status205 :: Status -- | Reset Content 205 resetContent205 :: Status -- | Partial Content 206 status206 :: Status -- | Partial Content 206 partialContent206 :: Status -- | Multiple Choices 300 status300 :: Status -- | Multiple Choices 300 multipleChoices300 :: Status -- | Moved Permanently 301 status301 :: Status -- | Moved Permanently 301 movedPermanently301 :: Status -- | Found 302 status302 :: Status -- | Found 302 found302 :: Status -- | See Other 303 status303 :: Status -- | See Other 303 seeOther303 :: Status -- | Not Modified 304 status304 :: Status -- | Not Modified 304 notModified304 :: Status -- | Use Proxy 305 status305 :: Status -- | Use Proxy 305 useProxy305 :: Status -- | Temporary Redirect 307 status307 :: Status -- | Temporary Redirect 307 temporaryRedirect307 :: Status -- | Permanent Redirect 308 status308 :: Status -- | Permanent Redirect 308 permanentRedirect308 :: Status -- | Bad Request 400 status400 :: Status -- | Bad Request 400 badRequest400 :: Status -- | Unauthorized 401 status401 :: Status -- | Unauthorized 401 unauthorized401 :: Status -- | Payment Required 402 status402 :: Status -- | Payment Required 402 paymentRequired402 :: Status -- | Forbidden 403 status403 :: Status -- | Forbidden 403 forbidden403 :: Status -- | Not Found 404 status404 :: Status -- | Not Found 404 notFound404 :: Status -- | Method Not Allowed 405 status405 :: Status -- | Method Not Allowed 405 methodNotAllowed405 :: Status -- | Not Acceptable 406 status406 :: Status -- | Not Acceptable 406 notAcceptable406 :: Status -- | Proxy Authentication Required 407 status407 :: Status -- | Proxy Authentication Required 407 proxyAuthenticationRequired407 :: Status -- | Request Timeout 408 status408 :: Status -- | Request Timeout 408 requestTimeout408 :: Status -- | Conflict 409 status409 :: Status -- | Conflict 409 conflict409 :: Status -- | Gone 410 status410 :: Status -- | Gone 410 gone410 :: Status -- | Length Required 411 status411 :: Status -- | Length Required 411 lengthRequired411 :: Status -- | Precondition Failed 412 status412 :: Status -- | Precondition Failed 412 preconditionFailed412 :: Status -- | Request Entity Too Large 413 status413 :: Status -- | Request Entity Too Large 413 requestEntityTooLarge413 :: Status -- | Request-URI Too Long 414 status414 :: Status -- | Request-URI Too Long 414 requestURITooLong414 :: Status -- | Unsupported Media Type 415 status415 :: Status -- | Unsupported Media Type 415 unsupportedMediaType415 :: Status -- | Requested Range Not Satisfiable 416 status416 :: Status -- | Requested Range Not Satisfiable 416 requestedRangeNotSatisfiable416 :: Status -- | Expectation Failed 417 status417 :: Status -- | Expectation Failed 417 expectationFailed417 :: Status -- | I'm a teapot 418 status418 :: Status -- | I'm a teapot 418 imATeapot418 :: Status -- | Unprocessable Entity 422 (RFC 4918) status422 :: Status -- | Unprocessable Entity 422 (RFC 4918) unprocessableEntity422 :: Status -- | Upgrade Required 426 -- (https://tools.ietf.org/html/rfc7231#section-6.5.15) status426 :: Status -- | Upgrade Required 426 -- (https://tools.ietf.org/html/rfc7231#section-6.5.15) upgradeRequired426 :: Status -- | Precondition Required 428 (RFC 6585) status428 :: Status -- | Precondition Required 428 (RFC 6585) preconditionRequired428 :: Status -- | Too Many Requests 429 (RFC 6585) status429 :: Status -- | Too Many Requests 429 (RFC 6585) tooManyRequests429 :: Status -- | Request Header Fields Too Large 431 (RFC 6585) status431 :: Status -- | Request Header Fields Too Large 431 (RFC 6585) requestHeaderFieldsTooLarge431 :: Status -- | Internal Server Error 500 status500 :: Status -- | Internal Server Error 500 internalServerError500 :: Status -- | Not Implemented 501 status501 :: Status -- | Not Implemented 501 notImplemented501 :: Status -- | Bad Gateway 502 status502 :: Status -- | Bad Gateway 502 badGateway502 :: Status -- | Service Unavailable 503 status503 :: Status -- | Service Unavailable 503 serviceUnavailable503 :: Status -- | Gateway Timeout 504 status504 :: Status -- | Gateway Timeout 504 gatewayTimeout504 :: Status -- | HTTP Version Not Supported 505 status505 :: Status -- | Network Authentication Required 511 (RFC 6585) status511 :: Status -- | Network Authentication Required 511 (RFC 6585) networkAuthenticationRequired511 :: Status -- | HTTP Version Not Supported 505 httpVersionNotSupported505 :: Status -- | Informational class -- -- Checks if the status is in the 1XX range. statusIsInformational :: Status -> Bool -- | Successful class -- -- Checks if the status is in the 2XX range. statusIsSuccessful :: Status -> Bool -- | Redirection class -- -- Checks if the status is in the 3XX range. statusIsRedirection :: Status -> Bool -- | Client Error class -- -- Checks if the status is in the 4XX range. statusIsClientError :: Status -> Bool -- | Server Error class -- -- Checks if the status is in the 5XX range. statusIsServerError :: Status -> Bool instance GHC.Generics.Generic Network.HTTP.Types.Status.Status instance Data.Data.Data Network.HTTP.Types.Status.Status instance GHC.Show.Show Network.HTTP.Types.Status.Status instance GHC.Classes.Eq Network.HTTP.Types.Status.Status instance GHC.Classes.Ord Network.HTTP.Types.Status.Status instance GHC.Enum.Enum Network.HTTP.Types.Status.Status instance GHC.Enum.Bounded Network.HTTP.Types.Status.Status -- | Query strings generally have the following form: -- "key1=value1&key2=value2" -- --
--   >>> renderQuery False [("key1", Just "value1"), ("key2", Just "value2")]
--   "key1=value1&key2=value2"
--   
-- -- But if the value of key1 is Nothing, it becomes: -- key1&key2=value2 -- --
--   >>> renderQuery False [("key1", Nothing), ("key2", Just "value2")]
--   "key1&key2=value2"
--   
-- -- This module also provides type synonyms and functions to handle -- queries that do not allow/expect keys without values -- (SimpleQuery), handle queries which have partially escaped -- characters module Network.HTTP.Types.URI -- | A sequence of QueryItems. type Query = [QueryItem] -- | 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. type QueryItem = (ByteString, Maybe ByteString) -- | Renders the given Query into a ByteString. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderQuery :: Bool -> Query -> ByteString -- | Renders the given Query into a Builder. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderQueryBuilder :: Bool -> Query -> Builder -- | Split out the query string into a list of keys and values. A few -- importants points: -- -- parseQuery :: ByteString -> Query -- | 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. parseQueryReplacePlus :: Bool -> ByteString -> Query -- | Like Query, but with Text instead of ByteString -- (UTF8-encoded). type QueryText = [(Text, Maybe Text)] -- | Convert QueryText to Query. queryTextToQuery :: QueryText -> Query -- | Convert Query to QueryText (leniently decoding the -- UTF-8). queryToQueryText :: Query -> QueryText -- | Convert QueryText to a Builder. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderQueryText :: Bool -> QueryText -> Builder -- | Parse a QueryText from a ByteString. See -- parseQuery for details. -- --
--   queryToQueryText . parseQuery
--   
parseQueryText :: ByteString -> QueryText -- | A sequence of SimpleQueryItems. type SimpleQuery = [SimpleQueryItem] -- | Simplified query item type without support for parameter-less items. type SimpleQueryItem = (ByteString, ByteString) -- | Convert SimpleQuery to Query. simpleQueryToQuery :: SimpleQuery -> Query -- | Render the given SimpleQuery into a ByteString. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderSimpleQuery :: Bool -> SimpleQuery -> ByteString -- | Parse SimpleQuery from a ByteString. -- -- This uses parseQuery under the hood, and will transform any -- Nothing values into an empty ByteString. parseSimpleQuery :: ByteString -> SimpleQuery -- | Query with some characters that should not be escaped. -- -- General form: a=b&c=d:e+f&g=h type PartialEscapeQuery = [PartialEscapeQueryItem] -- | 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. type PartialEscapeQueryItem = (ByteString, [EscapeItem]) -- | 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. data EscapeItem -- | will be URL encoded QE :: ByteString -> EscapeItem -- | will NOT at all be URL encoded QN :: ByteString -> EscapeItem -- | 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"
--   
renderQueryPartialEscape :: Bool -> PartialEscapeQuery -> ByteString -- | Convert a PartialEscapeQuery to a Builder. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderQueryBuilderPartialEscape :: Bool -> PartialEscapeQuery -> Builder -- | 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"
--   
extractPath :: ByteString -> ByteString -- | Encode a whole path (path segments + query). encodePath :: [Text] -> Query -> Builder -- | Decode a whole path (path segments + query). decodePath :: ByteString -> ([Text], Query) -- | Encodes a list of path segments into a valid URL fragment. -- -- This function takes the following three steps: -- -- -- -- 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. encodePathSegments :: [Text] -> Builder -- | Like encodePathSegments, but without the initial slash. encodePathSegmentsRelative :: [Text] -> Builder -- | Parse a list of path segments from a valid URL fragment. -- -- Will also decode any percent-encoded characters. decodePathSegments :: ByteString -> [Text] -- | Percent-encoding for URLs. -- -- In short: -- -- -- --

In-depth explanation

-- -- This will substitute every byte with its percent-encoded equivalent -- unless: -- -- urlEncode :: Bool -> ByteString -> ByteString -- | Percent-encoding for URLs. -- -- Like urlEncode, but only makes the Builder. urlEncodeBuilder :: Bool -> ByteString -> Builder -- | Percent-decoding. -- -- If you want to replace any '+' with a space, use True. urlDecode :: Bool -> ByteString -> ByteString instance GHC.Classes.Ord Network.HTTP.Types.URI.EscapeItem instance GHC.Classes.Eq Network.HTTP.Types.URI.EscapeItem instance GHC.Show.Show Network.HTTP.Types.URI.EscapeItem -- | Some type classes to make more general functions when handling query -- strings. module Network.HTTP.Types.QueryLike -- | 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. class QueryLike a -- | Convert to Query. toQuery :: QueryLike a => a -> Query -- | Types which, in a Query-like key-value list, are used in the Key -- position. class QueryKeyLike a toQueryKey :: QueryKeyLike a => a -> ByteString -- | Types which, in a Query-like key-value list, are used in the Value -- position. class QueryValueLike a toQueryValue :: QueryValueLike a => a -> Maybe ByteString instance (Network.HTTP.Types.QueryLike.QueryKeyLike k, Network.HTTP.Types.QueryLike.QueryValueLike v) => Network.HTTP.Types.QueryLike.QueryLike [(k, v)] instance (Network.HTTP.Types.QueryLike.QueryKeyLike k, Network.HTTP.Types.QueryLike.QueryValueLike v) => Network.HTTP.Types.QueryLike.QueryLike [GHC.Maybe.Maybe (k, v)] instance Network.HTTP.Types.QueryLike.QueryValueLike Data.ByteString.Internal.ByteString instance Network.HTTP.Types.QueryLike.QueryValueLike Data.ByteString.Lazy.Internal.ByteString instance Network.HTTP.Types.QueryLike.QueryValueLike Data.Text.Internal.Text instance Network.HTTP.Types.QueryLike.QueryValueLike [GHC.Types.Char] instance Network.HTTP.Types.QueryLike.QueryValueLike a => Network.HTTP.Types.QueryLike.QueryValueLike (GHC.Maybe.Maybe a) instance Network.HTTP.Types.QueryLike.QueryKeyLike Data.ByteString.Internal.ByteString instance Network.HTTP.Types.QueryLike.QueryKeyLike Data.ByteString.Lazy.Internal.ByteString instance Network.HTTP.Types.QueryLike.QueryKeyLike Data.Text.Internal.Text instance Network.HTTP.Types.QueryLike.QueryKeyLike [GHC.Types.Char] -- | Types and constants to describe the HTTP version. module Network.HTTP.Types.Version -- | HTTP Version. -- -- Note that the Show instance is intended merely for debugging. data HttpVersion HttpVersion :: !Int -> !Int -> HttpVersion [httpMajor] :: HttpVersion -> !Int [httpMinor] :: HttpVersion -> !Int -- | HTTP 0.9 http09 :: HttpVersion -- | HTTP 1.0 http10 :: HttpVersion -- | HTTP 1.1 http11 :: HttpVersion -- | HTTP 2.0 http20 :: HttpVersion instance GHC.Generics.Generic Network.HTTP.Types.Version.HttpVersion instance Data.Data.Data Network.HTTP.Types.Version.HttpVersion instance GHC.Classes.Ord Network.HTTP.Types.Version.HttpVersion instance GHC.Classes.Eq Network.HTTP.Types.Version.HttpVersion instance GHC.Show.Show Network.HTTP.Types.Version.HttpVersion module Network.HTTP.Types -- | HTTP method (flat ByteString type). type Method = ByteString -- | HTTP GET Method methodGet :: Method -- | HTTP POST Method methodPost :: Method -- | HTTP HEAD Method methodHead :: Method -- | HTTP PUT Method methodPut :: Method -- | HTTP DELETE Method methodDelete :: Method -- | HTTP TRACE Method methodTrace :: Method -- | HTTP CONNECT Method methodConnect :: Method -- | HTTP OPTIONS Method methodOptions :: Method -- | HTTP PATCH Method methodPatch :: Method -- | HTTP standard method (as defined by RFC 2616, and PATCH which is -- defined by RFC 5789). data StdMethod GET :: StdMethod POST :: StdMethod HEAD :: StdMethod PUT :: StdMethod DELETE :: StdMethod TRACE :: StdMethod CONNECT :: StdMethod OPTIONS :: StdMethod PATCH :: StdMethod -- | Convert a method ByteString to a StdMethod if -- possible. parseMethod :: Method -> Either ByteString StdMethod -- | Convert an algebraic method to a ByteString. -- --
--   renderMethod (parseMethod bs) == bs
--   
renderMethod :: Either ByteString StdMethod -> Method -- | Convert a StdMethod to a ByteString. renderStdMethod :: StdMethod -> Method -- | HTTP Version. -- -- Note that the Show instance is intended merely for debugging. data HttpVersion HttpVersion :: !Int -> !Int -> HttpVersion [httpMajor] :: HttpVersion -> !Int [httpMinor] :: HttpVersion -> !Int -- | HTTP 0.9 http09 :: HttpVersion -- | HTTP 1.0 http10 :: HttpVersion -- | HTTP 1.1 http11 :: HttpVersion -- | HTTP 2.0 http20 :: HttpVersion -- | 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. data Status Status :: Int -> ByteString -> Status [statusCode] :: Status -> Int [statusMessage] :: Status -> ByteString -- | Create a Status from a status code and message. mkStatus :: Int -> ByteString -> Status -- | Continue 100 status100 :: Status -- | Continue 100 continue100 :: Status -- | Switching Protocols 101 status101 :: Status -- | Switching Protocols 101 switchingProtocols101 :: Status -- | OK 200 status200 :: Status -- | OK 200 ok200 :: Status -- | Created 201 status201 :: Status -- | Created 201 created201 :: Status -- | Accepted 202 status202 :: Status -- | Accepted 202 accepted202 :: Status -- | Non-Authoritative Information 203 status203 :: Status -- | Non-Authoritative Information 203 nonAuthoritative203 :: Status -- | No Content 204 status204 :: Status -- | No Content 204 noContent204 :: Status -- | Reset Content 205 status205 :: Status -- | Reset Content 205 resetContent205 :: Status -- | Partial Content 206 status206 :: Status -- | Partial Content 206 partialContent206 :: Status -- | Multiple Choices 300 status300 :: Status -- | Multiple Choices 300 multipleChoices300 :: Status -- | Moved Permanently 301 status301 :: Status -- | Moved Permanently 301 movedPermanently301 :: Status -- | Found 302 status302 :: Status -- | Found 302 found302 :: Status -- | See Other 303 status303 :: Status -- | See Other 303 seeOther303 :: Status -- | Not Modified 304 status304 :: Status -- | Not Modified 304 notModified304 :: Status -- | Use Proxy 305 status305 :: Status -- | Use Proxy 305 useProxy305 :: Status -- | Temporary Redirect 307 status307 :: Status -- | Temporary Redirect 307 temporaryRedirect307 :: Status -- | Permanent Redirect 308 status308 :: Status -- | Permanent Redirect 308 permanentRedirect308 :: Status -- | Bad Request 400 status400 :: Status -- | Bad Request 400 badRequest400 :: Status -- | Unauthorized 401 status401 :: Status -- | Unauthorized 401 unauthorized401 :: Status -- | Payment Required 402 status402 :: Status -- | Payment Required 402 paymentRequired402 :: Status -- | Forbidden 403 status403 :: Status -- | Forbidden 403 forbidden403 :: Status -- | Not Found 404 status404 :: Status -- | Not Found 404 notFound404 :: Status -- | Method Not Allowed 405 status405 :: Status -- | Method Not Allowed 405 methodNotAllowed405 :: Status -- | Not Acceptable 406 status406 :: Status -- | Not Acceptable 406 notAcceptable406 :: Status -- | Proxy Authentication Required 407 status407 :: Status -- | Proxy Authentication Required 407 proxyAuthenticationRequired407 :: Status -- | Request Timeout 408 status408 :: Status -- | Request Timeout 408 requestTimeout408 :: Status -- | Conflict 409 status409 :: Status -- | Conflict 409 conflict409 :: Status -- | Gone 410 status410 :: Status -- | Gone 410 gone410 :: Status -- | Length Required 411 status411 :: Status -- | Length Required 411 lengthRequired411 :: Status -- | Precondition Failed 412 status412 :: Status -- | Precondition Failed 412 preconditionFailed412 :: Status -- | Request Entity Too Large 413 status413 :: Status -- | Request Entity Too Large 413 requestEntityTooLarge413 :: Status -- | Request-URI Too Long 414 status414 :: Status -- | Request-URI Too Long 414 requestURITooLong414 :: Status -- | Unsupported Media Type 415 status415 :: Status -- | Unsupported Media Type 415 unsupportedMediaType415 :: Status -- | Requested Range Not Satisfiable 416 status416 :: Status -- | Requested Range Not Satisfiable 416 requestedRangeNotSatisfiable416 :: Status -- | Expectation Failed 417 status417 :: Status -- | Expectation Failed 417 expectationFailed417 :: Status -- | I'm a teapot 418 status418 :: Status -- | I'm a teapot 418 imATeapot418 :: Status -- | Unprocessable Entity 422 (RFC 4918) status422 :: Status -- | Unprocessable Entity 422 (RFC 4918) unprocessableEntity422 :: Status -- | Precondition Required 428 (RFC 6585) status428 :: Status -- | Precondition Required 428 (RFC 6585) preconditionRequired428 :: Status -- | Too Many Requests 429 (RFC 6585) status429 :: Status -- | Too Many Requests 429 (RFC 6585) tooManyRequests429 :: Status -- | Request Header Fields Too Large 431 (RFC 6585) status431 :: Status -- | Request Header Fields Too Large 431 (RFC 6585) requestHeaderFieldsTooLarge431 :: Status -- | Internal Server Error 500 status500 :: Status -- | Internal Server Error 500 internalServerError500 :: Status -- | Not Implemented 501 status501 :: Status -- | Not Implemented 501 notImplemented501 :: Status -- | Bad Gateway 502 status502 :: Status -- | Bad Gateway 502 badGateway502 :: Status -- | Service Unavailable 503 status503 :: Status -- | Service Unavailable 503 serviceUnavailable503 :: Status -- | Gateway Timeout 504 status504 :: Status -- | Gateway Timeout 504 gatewayTimeout504 :: Status -- | HTTP Version Not Supported 505 status505 :: Status -- | HTTP Version Not Supported 505 httpVersionNotSupported505 :: Status -- | Network Authentication Required 511 (RFC 6585) status511 :: Status -- | Network Authentication Required 511 (RFC 6585) networkAuthenticationRequired511 :: Status -- | Informational class -- -- Checks if the status is in the 1XX range. statusIsInformational :: Status -> Bool -- | Successful class -- -- Checks if the status is in the 2XX range. statusIsSuccessful :: Status -> Bool -- | Redirection class -- -- Checks if the status is in the 3XX range. statusIsRedirection :: Status -> Bool -- | Client Error class -- -- Checks if the status is in the 4XX range. statusIsClientError :: Status -> Bool -- | Server Error class -- -- Checks if the status is in the 5XX range. statusIsServerError :: Status -> Bool -- | 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") type Header = (HeaderName, ByteString) -- | A case-insensitive name of a header field. -- -- This is the part of the header field before the colon: HeaderName: -- some value type HeaderName = CI ByteString -- | A list of Headers. -- -- Same type as ResponseHeaders, but useful to differentiate in -- type signatures. type RequestHeaders = [Header] -- | A list of Headers. -- -- Same type as RequestHeaders, but useful to differentiate in -- type signatures. type ResponseHeaders = [Header] -- | Accept hAccept :: HeaderName -- | Accept-Language hAcceptLanguage :: HeaderName -- | Authorization hAuthorization :: HeaderName -- | Cache-Control hCacheControl :: HeaderName -- | Cookie hCookie :: HeaderName -- | Connection hConnection :: HeaderName -- | Content-Encoding hContentEncoding :: HeaderName -- | Content-Length hContentLength :: HeaderName -- | Content-MD5 -- -- This header has been obsoleted in RFC 9110. hContentMD5 :: HeaderName -- | Content-Type hContentType :: HeaderName -- | Date hDate :: HeaderName -- | If-Modified-Since hIfModifiedSince :: HeaderName -- | If-Range hIfRange :: HeaderName -- | Last-Modified hLastModified :: HeaderName -- | Location hLocation :: HeaderName -- | Range hRange :: HeaderName -- | Referer hReferer :: HeaderName -- | Server hServer :: HeaderName -- | User-Agent hUserAgent :: HeaderName -- | An individual byte range. -- -- Negative indices are not allowed! data ByteRange ByteRangeFrom :: !Integer -> ByteRange ByteRangeFromTo :: !Integer -> !Integer -> ByteRange ByteRangeSuffix :: !Integer -> ByteRange -- | Turns a byte range into a byte string Builder. renderByteRangeBuilder :: ByteRange -> Builder -- | Renders a byte range into a ByteString. -- --
--   >>> renderByteRange (ByteRangeFrom 2048)
--   "2048-"
--   
renderByteRange :: ByteRange -> ByteString -- | A list of byte ranges. type ByteRanges = [ByteRange] -- | Turns a list of byte ranges into a byte string Builder. renderByteRangesBuilder :: ByteRanges -> Builder -- | Renders a list of byte ranges into a ByteString. -- --
--   >>> renderByteRanges [ByteRangeFrom 2048, ByteRangeSuffix 20]
--   "bytes=2048-,-20"
--   
renderByteRanges :: ByteRanges -> ByteString -- | Parse the value of a Range header into a ByteRanges. -- --
--   >>> parseByteRanges "error"
--   Nothing
--   
--   >>> parseByteRanges "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]
--   
parseByteRanges :: ByteString -> Maybe ByteRanges -- | A sequence of QueryItems. type Query = [QueryItem] -- | 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. type QueryItem = (ByteString, Maybe ByteString) -- | Renders the given Query into a ByteString. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderQuery :: Bool -> Query -> ByteString -- | Renders the given Query into a Builder. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderQueryBuilder :: Bool -> Query -> Builder -- | Split out the query string into a list of keys and values. A few -- importants points: -- -- parseQuery :: ByteString -> Query -- | 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. parseQueryReplacePlus :: Bool -> ByteString -> Query -- | Like Query, but with Text instead of ByteString -- (UTF8-encoded). type QueryText = [(Text, Maybe Text)] -- | Convert QueryText to Query. queryTextToQuery :: QueryText -> Query -- | Convert Query to QueryText (leniently decoding the -- UTF-8). queryToQueryText :: Query -> QueryText -- | Convert QueryText to a Builder. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderQueryText :: Bool -> QueryText -> Builder -- | Parse a QueryText from a ByteString. See -- parseQuery for details. -- --
--   queryToQueryText . parseQuery
--   
parseQueryText :: ByteString -> QueryText -- | A sequence of SimpleQueryItems. type SimpleQuery = [SimpleQueryItem] -- | Simplified query item type without support for parameter-less items. type SimpleQueryItem = (ByteString, ByteString) -- | Convert SimpleQuery to Query. simpleQueryToQuery :: SimpleQuery -> Query -- | Render the given SimpleQuery into a ByteString. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderSimpleQuery :: Bool -> SimpleQuery -> ByteString -- | Parse SimpleQuery from a ByteString. -- -- This uses parseQuery under the hood, and will transform any -- Nothing values into an empty ByteString. parseSimpleQuery :: ByteString -> SimpleQuery -- | Query with some characters that should not be escaped. -- -- General form: a=b&c=d:e+f&g=h type PartialEscapeQuery = [PartialEscapeQueryItem] -- | 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. type PartialEscapeQueryItem = (ByteString, [EscapeItem]) -- | 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. data EscapeItem -- | will be URL encoded QE :: ByteString -> EscapeItem -- | will NOT at all be URL encoded QN :: ByteString -> EscapeItem -- | 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"
--   
renderQueryPartialEscape :: Bool -> PartialEscapeQuery -> ByteString -- | Convert a PartialEscapeQuery to a Builder. -- -- If you want a question mark (?) added to the front of the -- result, use True. renderQueryBuilderPartialEscape :: Bool -> PartialEscapeQuery -> Builder -- | 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. class QueryLike a -- | Convert to Query. toQuery :: QueryLike a => a -> Query -- | 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"
--   
extractPath :: ByteString -> ByteString -- | Encode a whole path (path segments + query). encodePath :: [Text] -> Query -> Builder -- | Decode a whole path (path segments + query). decodePath :: ByteString -> ([Text], Query) -- | Encodes a list of path segments into a valid URL fragment. -- -- This function takes the following three steps: -- -- -- -- 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. encodePathSegments :: [Text] -> Builder -- | Like encodePathSegments, but without the initial slash. encodePathSegmentsRelative :: [Text] -> Builder -- | Parse a list of path segments from a valid URL fragment. -- -- Will also decode any percent-encoded characters. decodePathSegments :: ByteString -> [Text] -- | Percent-encoding for URLs. -- -- In short: -- -- -- --

In-depth explanation

-- -- This will substitute every byte with its percent-encoded equivalent -- unless: -- -- urlEncode :: Bool -> ByteString -> ByteString -- | Percent-encoding for URLs. -- -- Like urlEncode, but only makes the Builder. urlEncodeBuilder :: Bool -> ByteString -> Builder -- | Percent-decoding. -- -- If you want to replace any '+' with a space, use True. urlDecode :: Bool -> ByteString -> ByteString