-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Types and serialization for HTTP -- -- Types and serialization for HTTP. This includes things like request -- line, status line, and headers. There is also a collection type for -- headers that supports fast, case-insensitive lookup. @package http-interchange @version 0.3.1.0 module Http.Bodied -- | An HTTP request or response with a body. data Bodied a Bodied :: !a -> !Chunks -> Bodied a -- | The request or response. [metadata] :: Bodied a -> !a -- | The body. [body] :: Bodied a -> !Chunks instance GHC.Classes.Eq a => GHC.Classes.Eq (Http.Bodied.Bodied a) instance GHC.Show.Show a => GHC.Show.Show (Http.Bodied.Bodied a) module Http.Header -- | An HTTP header. This type does not enforce a restricted character set. -- If, for example, the user creates a header whose key has a colon -- character, the resulting request will be malformed. data Header Header :: {-# UNPACK #-} !Text -> {-# UNPACK #-} !Text -> Header [name] :: Header -> {-# UNPACK #-} !Text [value] :: Header -> {-# UNPACK #-} !Text -- | Parse headers. Expects two CRLF sequences in a row at the end. Fails -- if leftovers are encountered. decodeMany :: Int -> Bytes -> Maybe (SmallArray Header) -- | Parse a single HTTP header including the trailing CRLF sequence. From -- RFC 7230: -- --
--   header-field   = field-name ":" OWS field-value OWS
--   field-name     = token
--   field-value    = *( field-content / obs-fold )
--   field-content  = field-vchar [ 1*( SP / HTAB ) field-vchar ]
--   field-vchar    = VCHAR / obs-text
--   
parser :: Parser () s Header parserSmallArray :: Int -> Parser () s (SmallArray Header) -- | Encode a header. Includes the trailing CRLF sequence. builder :: Header -> Builder builderSmallArray :: SmallArray Header -> Builder instance GHC.Show.Show Http.Header.Header module Http.Headers -- | Collection of HTTP headers. Supports case-insensitive lookup. This is -- intended to be used for small collections of headers. Expect degraded -- performance if this is used for collections of more than 128 headers. -- -- This preserves the original order of the headers and the original case -- of the header names. data Headers -- | Many headers cannot appear more than once. This is part of the return -- type for lookup, and it helps us track whether the lookup -- failure was the result of something that might be expected (the header -- was Missing) or something that is definitely a mistake (the -- header was duplicated). data LookupException Duplicate :: LookupException Missing :: LookupException -- | Convert array of headers to a Headers collection that supports -- efficient lookup. fromArray :: SmallArray Header -> Headers -- | Convert list of headers to a Headers collection that supports -- efficient lookup. fromList :: [Header] -> Headers -- | Add a header to the beginning of the headers. cons :: Header -> Headers -> Headers -- | Add a header to the beginning of the headers. snoc :: Headers -> Header -> Headers -- | Recover the original headers from from the Headers collection. -- This is O(1) and is most commonly used to fold over the -- headers. toArray :: Headers -> SmallArray Header -- | Lookup a header that should not appear more than one time and verify -- that it did not occur more than once. If it appears more than once (or -- less than once), returns a LookupException. lookup :: Text -> Headers -> Either LookupException Header -- | Case insensitive lookup of an HTTP header. If the header is present, -- returns both the original header name (may differs in case from the -- header name searched for) and the header value. Only returns the first -- occurrence of the header. lookupFirst :: Text -> Headers -> Maybe Header -- | Lookup a header that may appear more than once. Some headers (e.g. -- Set-Cookie, X-Forwarded-For) are allowed to appear -- multiple times. This returns all the headers that matched along with -- their original names. lookupAll :: Text -> Headers -> SmallArray Header lookupContentType :: Headers -> Either LookupException Header lookupContentLength :: Headers -> Either LookupException Header lookupTransferEncoding :: Headers -> Either LookupException Header lookupHost :: Headers -> Either LookupException Header lookupAccept :: Headers -> Either LookupException Header lookupDate :: Headers -> Either LookupException Header snocContentLength :: Headers -> Text -> Headers -- | Returns True if both the Content-Length and -- Transfer-Encoding headers are missing. lacksContentLengthAndTransferEncoding :: Headers -> Bool instance GHC.Base.Monoid Http.Headers.Headers instance GHC.Base.Semigroup Http.Headers.Headers instance GHC.Show.Show Http.Headers.Headers module Http.Request -- | The request line and the request headers. data Request Request :: !RequestLine -> !Headers -> Request [$sel:requestLine:Request] :: Request -> !RequestLine [$sel:headers:Request] :: Request -> !Headers -- | An HTTP request line data RequestLine RequestLine :: {-# UNPACK #-} !Text -> {-# UNPACK #-} !Text -> RequestLine [$sel:method:RequestLine] :: RequestLine -> {-# UNPACK #-} !Text [$sel:path:RequestLine] :: RequestLine -> {-# UNPACK #-} !Text builder :: Request -> Builder toChunks :: Request -> Chunks toChunksOnto :: Request -> Chunks -> Chunks -- | This adds the Content-Length header. It must not already be present. bodiedToChunks :: Bodied Request -> Chunks instance GHC.Show.Show Http.Request.RequestLine instance GHC.Show.Show Http.Request.Request module Http.Response -- | The response status line and the response headers. data Response Response :: !StatusLine -> !Headers -> Response [$sel:statusLine:Response] :: Response -> !StatusLine [$sel:headers:Response] :: Response -> !Headers data StatusLine StatusLine :: !Word16 -> {-# UNPACK #-} !Text -> StatusLine [$sel:statusCode:StatusLine] :: StatusLine -> !Word16 [$sel:statusReason:StatusLine] :: StatusLine -> {-# UNPACK #-} !Text -- | Decode the response status line and the response headers. Fails if any -- extraneous input is present after the double CRLF sequence that ends -- the headers. decode :: Int -> Bytes -> Maybe Response instance GHC.Show.Show Http.Response.StatusLine instance GHC.Show.Show Http.Response.Response module Http.Types -- | The request line and the request headers. data Request Request :: !RequestLine -> !Headers -> Request [$sel:requestLine:Request] :: Request -> !RequestLine [$sel:headers:Request] :: Request -> !Headers -- | An HTTP request line data RequestLine RequestLine :: {-# UNPACK #-} !Text -> {-# UNPACK #-} !Text -> RequestLine [$sel:method:RequestLine] :: RequestLine -> {-# UNPACK #-} !Text [$sel:path:RequestLine] :: RequestLine -> {-# UNPACK #-} !Text -- | The response status line and the response headers. data Response Response :: !StatusLine -> !Headers -> Response [$sel:statusLine:Response] :: Response -> !StatusLine [$sel:headers:Response] :: Response -> !Headers data StatusLine StatusLine :: !Word16 -> {-# UNPACK #-} !Text -> StatusLine [$sel:statusCode:StatusLine] :: StatusLine -> !Word16 [$sel:statusReason:StatusLine] :: StatusLine -> {-# UNPACK #-} !Text -- | Collection of HTTP headers. Supports case-insensitive lookup. This is -- intended to be used for small collections of headers. Expect degraded -- performance if this is used for collections of more than 128 headers. -- -- This preserves the original order of the headers and the original case -- of the header names. data Headers -- | An HTTP header. This type does not enforce a restricted character set. -- If, for example, the user creates a header whose key has a colon -- character, the resulting request will be malformed. data Header Header :: {-# UNPACK #-} !Text -> {-# UNPACK #-} !Text -> Header [name] :: Header -> {-# UNPACK #-} !Text [value] :: Header -> {-# UNPACK #-} !Text -- | Many headers cannot appear more than once. This is part of the return -- type for lookup, and it helps us track whether the lookup -- failure was the result of something that might be expected (the header -- was Missing) or something that is definitely a mistake (the -- header was duplicated). data LookupException Duplicate :: LookupException Missing :: LookupException -- | An HTTP request or response with a body. data Bodied a Bodied :: !a -> !Chunks -> Bodied a -- | The request or response. [metadata] :: Bodied a -> !a -- | The body. [body] :: Bodied a -> !Chunks