WIP: Separate request and response headers

- Add simplified headers creation mechanism
This commit is contained in:
sigma-andex 2022-06-13 20:28:24 +01:00
parent d63e03a9be
commit f8e53eca35
6 changed files with 191 additions and 176 deletions

View File

@ -22,8 +22,8 @@ module HTTPurple
import Data.Generic.Rep (class Generic)
import HTTPurple.Body (toBuffer, toStream, toString)
import HTTPurple.Cont (usingCont)
import HTTPurple.Headers (Headers, empty, header, headers)
import HTTPurple.Json (JsonDecoder(..), JsonEncoder(..), fromJson, jsonHeader, jsonHeaders, toJson)
import HTTPurple.Headers (RequestHeaders, ResponseHeaders, empty, header, headers)
import HTTPurple.Json (JsonDecoder(..), JsonEncoder(..), fromJson, jsonHeaders, toJson)
import HTTPurple.Lookup (at, has, lookup, (!!), (!?), (!@))
import HTTPurple.Method (Method(..))
import HTTPurple.Path (Path)

View File

@ -19,7 +19,7 @@ import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Class (liftEffect)
import Effect.Ref (Ref)
import Effect.Ref (modify, new, read, write) as Ref
import HTTPurple.Headers (Headers, header)
import HTTPurple.Headers (RequestHeaders, mkRequestHeader)
import Node.Buffer (Buffer, concat, fromString, size)
import Node.Buffer (toString) as Buffer
import Node.Encoding (Encoding(UTF8))
@ -103,7 +103,7 @@ class Body b where
-- | things like `Content-Type`, `Content-Length`, and `Transfer-Encoding`.
-- | Note that any headers passed in a response helper such as `ok'` will take
-- | precedence over these.
defaultHeaders :: b -> Effect Headers
defaultHeaders :: b -> Effect RequestHeaders
-- | Given a body value and a Node HTTP `Response` value, write the body value
-- | to the Node response.
write :: b -> Response -> Aff Unit
@ -126,7 +126,7 @@ instance Body String where
-- | using `Buffer.size`, and to send the response, we just write the buffer to
-- | the stream and end the stream.
instance Body Buffer where
defaultHeaders buf = header "Content-Length" <$> show <$> size buf
defaultHeaders buf = mkRequestHeader "Content-Length" <$> show <$> size buf
write body response = makeAff \done -> do
let stream = responseAsStream response
void $ Stream.write stream body $ const $ end stream $ const $ done $ Right unit
@ -138,7 +138,7 @@ instance Body Buffer where
instance
TypeEquals (Stream r) (Readable s) =>
Body (Stream r) where
defaultHeaders _ = pure $ header "Transfer-Encoding" "chunked"
defaultHeaders _ = pure $ mkRequestHeader "Transfer-Encoding" "chunked"
write body response = makeAff \done -> do
let stream = to body
void $ pipe stream $ responseAsStream response

View File

@ -1,76 +1,158 @@
module HTTPurple.Headers
( Headers(..)
( RequestHeaders(..)
, ResponseHeaders(..)
, class ToHeaders
, class ToHeadersHelper
, empty
, headers
, header
, headers
, headersImpl
, mkRequestHeader
, mkRequestHeaders
, read
, toResponseHeaders
, write
) where
)
where
import Prelude
import Data.Array as Array
import Data.Foldable (foldl)
import Data.FoldableWithIndex (foldMapWithIndex)
import Data.Map (Map, insert, singleton, union)
import Data.Map (empty) as Map
import Data.Newtype (class Newtype, unwrap)
import Data.Newtype (class Newtype, un, unwrap)
import Data.String.CaseInsensitive (CaseInsensitiveString(CaseInsensitiveString))
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.TraversableWithIndex (traverseWithIndex)
import Data.Tuple (Tuple(Tuple))
import Effect (Effect)
import Foreign.Object (fold)
import HTTPurple.Lookup (class Lookup, (!!))
import Node.HTTP (Request, Response, requestHeaders, setHeader)
import Node.HTTP (Request, Response, requestHeaders, setHeaders)
import Prim.Row as Row
import Prim.RowList (class RowToList, Cons, Nil)
import Record as Record
import Type.Proxy (Proxy(..))
-- | The `Headers` type is just sugar for a `Object` of `Strings`
-- | The `RequestHeaders` type is just sugar for a `Object` of `Strings`
-- | that represents the set of headers in an HTTP request or response.
newtype Headers = Headers (Map CaseInsensitiveString String)
newtype RequestHeaders = RequestHeaders (Map CaseInsensitiveString String)
derive instance newtypeHeaders :: Newtype Headers _
derive instance Newtype RequestHeaders _
-- | Given a string, return a `Maybe` containing the value of the matching
-- | header, if there is any.
instance lookup :: Lookup Headers String String where
lookup (Headers headers') key = headers' !! key
instance Lookup RequestHeaders String String where
lookup (RequestHeaders headers') key = headers' !! key
-- | Allow a `Headers` to be represented as a string. This string is formatted
-- | in HTTP headers format.
instance show :: Show Headers where
show (Headers headers') = foldMapWithIndex showField headers' <> "\n"
instance Show RequestHeaders where
show (RequestHeaders headers') = foldMapWithIndex showField headers' <> "\n"
where
showField key value = unwrap key <> ": " <> value <> "\n"
-- | Compare two `Headers` objects by comparing the underlying `Objects`.
instance eq :: Eq Headers where
eq (Headers a) (Headers b) = eq a b
instance Eq RequestHeaders where
eq (RequestHeaders a) (RequestHeaders b) = eq a b
-- | Allow one `Headers` objects to be appended to another.
instance semigroup :: Semigroup Headers where
append (Headers a) (Headers b) = Headers $ union b a
-- | Allow one `RequestHeaders` objects to be appended to another.
instance Semigroup RequestHeaders where
append (RequestHeaders a) (RequestHeaders b) = RequestHeaders $ union b a
-- | The `RequestHeaders` type is just sugar for a `Object` of `Strings`
-- | that represents the set of headers in an HTTP request or response.
newtype ResponseHeaders = ResponseHeaders (Map CaseInsensitiveString (Array String))
-- | Allow one `ResponseHeaders` objects to be appended to another.
instance Semigroup ResponseHeaders where
append (ResponseHeaders a) (ResponseHeaders b) = ResponseHeaders $ union b a
-- | Allow a `RequestHeaders` to be represented as a string. This string is formatted
-- | in HTTP headers format.
instance Show ResponseHeaders where
show (ResponseHeaders headers') = foldMapWithIndex showField headers' <> "\n"
where
showField key value = Array.foldMap (\v -> unwrap key <> ": " <> v <> "\n") value
-- | Get the headers out of a HTTP `Request` object.
read :: Request -> Headers
read = requestHeaders >>> fold insertField Map.empty >>> Headers
read :: Request -> RequestHeaders
read = requestHeaders >>> fold insertField Map.empty >>> RequestHeaders
where
insertField x key value = insert (CaseInsensitiveString key) value x
-- | Given an HTTP `Response` and a `Headers` object, return an effect that will
-- | write the `Headers` to the `Response`.
write :: Response -> Headers -> Effect Unit
write response (Headers headers') = void $ traverseWithIndex writeField headers'
-- | Given an HTTP `Response` and a `ResponseHeaders` object, return an effect that will
-- | write the `ResponseHeaders` to the `Response`.
write :: Response -> ResponseHeaders -> Effect Unit
write response (ResponseHeaders headers') = void $ traverseWithIndex writeField headers'
where
writeField key value = setHeader response (unwrap key) value
writeField key values = setHeaders response (unwrap key) values
-- | Return a `Headers` containing nothing.
empty :: Headers
empty = Headers Map.empty
-- | Return a `ResponseHeaders` containing nothing.
empty :: ResponseHeaders
empty = ResponseHeaders Map.empty
-- | Convert an `Array` of `Tuples` of 2 `Strings` to a `Headers` object.
headers :: Array (Tuple String String) -> Headers
headers = foldl insertField Map.empty >>> Headers
-- -- | Convert an `Array` of `Tuples` of 2 `Strings` to a `Headers` object.
mkRequestHeaders :: Array (Tuple String String) -> RequestHeaders
mkRequestHeaders = foldl insertField Map.empty >>> RequestHeaders
where
insertField x (Tuple key value) = insert (CaseInsensitiveString key) value x
-- | Create a singleton header from a key-value pair.
header :: String -> String -> Headers
header key = singleton (CaseInsensitiveString key) >>> Headers
mkRequestHeader :: String -> String -> RequestHeaders
mkRequestHeader key = singleton (CaseInsensitiveString key) >>> RequestHeaders
-- | Create a singleton header from a key-value pair.
header :: String -> String -> ResponseHeaders
header key = Array.singleton >>> singleton (CaseInsensitiveString key) >>> ResponseHeaders
toResponseHeaders :: RequestHeaders -> ResponseHeaders
toResponseHeaders = un RequestHeaders >>> map (Array.singleton) >>> ResponseHeaders
class ToHeadersHelper :: forall k. Row Type -> k -> Constraint
class ToHeadersHelper r rl where
headersImpl :: Proxy rl -> Record r -> ResponseHeaders
instance ToHeadersHelper r (Nil) where
headersImpl _ _ = empty
else instance
( IsSymbol sym
, RowToList r rl
, RowToList tail tailRL
, Row.Cons sym String tail r
, Row.Lacks sym tail
, ToHeadersHelper tail tailRL
) =>
ToHeadersHelper r (Cons sym String tailRL) where
headersImpl _ rec = header key value <> headersImpl (Proxy :: Proxy tailRL) tail
where
key = reflectSymbol (Proxy :: Proxy sym)
value = Record.get (Proxy :: Proxy sym) rec
tail = Record.delete (Proxy :: Proxy sym) rec
else instance
( IsSymbol sym
, RowToList r rl
, RowToList tail tailRL
, Row.Cons sym (Array String) tail r
, Row.Lacks sym tail
, ToHeadersHelper tail tailRL
) =>
ToHeadersHelper r (Cons sym (Array String) tailRL) where
headersImpl _ rec = constructHeaders key value <> headersImpl (Proxy :: Proxy tailRL) tail
where
constructHeaders k = singleton (CaseInsensitiveString k) >>> ResponseHeaders
key = reflectSymbol (Proxy :: Proxy sym)
value = Record.get (Proxy :: Proxy sym) rec
tail = Record.delete (Proxy :: Proxy sym) rec
class ToHeaders r where
headers :: r -> ResponseHeaders
instance (RowToList r rl, ToHeadersHelper r rl) => ToHeaders (Record r) where
headers = headersImpl (Proxy :: Proxy rl)

View File

@ -3,7 +3,6 @@ module HTTPurple.Json
, JsonEncoder(..)
, fromJson
, fromJsonE
, jsonHeader
, jsonHeaders
, toJson
) where
@ -14,10 +13,9 @@ import Control.Monad.Cont (ContT(..))
import Data.Either (Either, either)
import Data.Function as Function
import Data.Newtype (class Newtype, un)
import Data.Tuple (Tuple(..))
import Effect.Aff.Class (class MonadAff)
import HTTPurple.Body (RequestBody, toString)
import HTTPurple.Headers (Headers, headers)
import HTTPurple.Headers (ResponseHeaders, headers)
import HTTPurple.Response (Response, badRequest)
newtype JsonDecoder err json = JsonDecoder (String -> Either err json)
@ -28,11 +26,8 @@ newtype JsonEncoder json = JsonEncoder (json -> String)
instance Newtype (JsonEncoder json) (json -> String)
jsonHeader :: Tuple String String
jsonHeader = Tuple "Content-Type" "application/json"
jsonHeaders :: Headers
jsonHeaders = headers [ jsonHeader ]
jsonHeaders :: ResponseHeaders
jsonHeaders = headers { "Content-Type": "application/json" }
fromJsonContinuation ::
forall err json m.

View File

@ -14,7 +14,7 @@ import Effect.Class (liftEffect)
import Foreign.Object (isEmpty, toArrayWithKey)
import HTTPurple.Body (RequestBody)
import HTTPurple.Body (read) as Body
import HTTPurple.Headers (Headers)
import HTTPurple.Headers (RequestHeaders)
import HTTPurple.Headers (read) as Headers
import HTTPurple.Method (Method)
import HTTPurple.Method (read) as Method
@ -36,7 +36,7 @@ type Request route =
, path :: Path
, query :: Query
, route :: route
, headers :: Headers
, headers :: RequestHeaders
, body :: RequestBody
, httpVersion :: Version
, url :: String

View File

@ -139,72 +139,10 @@ import Effect.Aff (Aff)
import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Class (class MonadEffect, liftEffect)
import HTTPurple.Body (class Body, defaultHeaders, write)
import HTTPurple.Headers (Headers, empty)
import HTTPurple.Headers (RequestHeaders, ResponseHeaders, empty, toResponseHeaders)
import HTTPurple.Headers (write) as Headers
import HTTPurple.Status (Status)
import HTTPurple.Status
( accepted
, alreadyReported
, badGateway
, badRequest
, conflict
, continue
, created
, expectationFailed
, failedDependency
, forbidden
, found
, gatewayTimeout
, gone
, hTTPVersionNotSupported
, iMUsed
, imATeapot
, insufficientStorage
, internalServerError
, lengthRequired
, locked
, loopDetected
, methodNotAllowed
, misdirectedRequest
, movedPermanently
, multiStatus
, multipleChoices
, networkAuthenticationRequired
, noContent
, nonAuthoritativeInformation
, notAcceptable
, notExtended
, notFound
, notImplemented
, notModified
, ok
, partialContent
, payloadTooLarge
, paymentRequired
, permanentRedirect
, preconditionFailed
, preconditionRequired
, processing
, proxyAuthenticationRequired
, rangeNotSatisfiable
, requestHeaderFieldsTooLarge
, requestTimeout
, resetContent
, seeOther
, serviceUnavailable
, switchingProtocols
, temporaryRedirect
, tooManyRequests
, uRITooLong
, unauthorized
, unavailableForLegalReasons
, unprocessableEntity
, unsupportedMediaType
, upgradeRequired
, useProxy
, variantAlsoNegotiates
, write
) as Status
import HTTPurple.Status (accepted, alreadyReported, badGateway, badRequest, conflict, continue, created, expectationFailed, failedDependency, forbidden, found, gatewayTimeout, gone, hTTPVersionNotSupported, iMUsed, imATeapot, insufficientStorage, internalServerError, lengthRequired, locked, loopDetected, methodNotAllowed, misdirectedRequest, movedPermanently, multiStatus, multipleChoices, networkAuthenticationRequired, noContent, nonAuthoritativeInformation, notAcceptable, notExtended, notFound, notImplemented, notModified, ok, partialContent, payloadTooLarge, paymentRequired, permanentRedirect, preconditionFailed, preconditionRequired, processing, proxyAuthenticationRequired, rangeNotSatisfiable, requestHeaderFieldsTooLarge, requestTimeout, resetContent, seeOther, serviceUnavailable, switchingProtocols, temporaryRedirect, tooManyRequests, uRITooLong, unauthorized, unavailableForLegalReasons, unprocessableEntity, unsupportedMediaType, upgradeRequired, useProxy, variantAlsoNegotiates, write) as Status
import Node.HTTP (Response) as HTTP
-- | The `ResponseM` type simply conveniently wraps up an HTTPurple monad that
@ -215,7 +153,7 @@ type ResponseM = Aff Response
-- | A `Response` is a status code, headers, and a body.
type Response =
{ status :: Status
, headers :: Headers
, headers :: ResponseHeaders
, writeBody :: HTTP.Response -> Aff Unit
}
@ -239,14 +177,14 @@ response' ::
MonadAff m =>
Body b =>
Status ->
Headers ->
ResponseHeaders ->
b ->
m Response
response' status headers body = liftEffect do
defaultHeaders' <- defaultHeaders body
pure
{ status
, headers: defaultHeaders' <> headers
, headers: toResponseHeaders defaultHeaders' <> headers
, writeBody: write body
}
@ -255,7 +193,7 @@ emptyResponse :: forall m. MonadAff m => Status -> m Response
emptyResponse status = emptyResponse' status empty
-- | The same as `emptyResponse` but with headers.
emptyResponse' :: forall m. MonadAff m => Status -> Headers -> m Response
emptyResponse' :: forall m. MonadAff m => Status -> ResponseHeaders -> m Response
emptyResponse' status headers = response' status headers ""
---------
@ -266,7 +204,7 @@ continue :: forall m. MonadAff m => m Response
continue = continue' empty
-- | 100 with headers
continue' :: forall m. MonadAff m => Headers -> m Response
continue' :: forall m. MonadAff m => ResponseHeaders -> m Response
continue' = emptyResponse' Status.continue
-- | 101
@ -274,7 +212,7 @@ switchingProtocols :: forall m. MonadAff m => m Response
switchingProtocols = switchingProtocols' empty
-- | 101 with headers
switchingProtocols' :: forall m. MonadAff m => Headers -> m Response
switchingProtocols' :: forall m. MonadAff m => ResponseHeaders -> m Response
switchingProtocols' = emptyResponse' Status.switchingProtocols
-- | 102
@ -282,7 +220,7 @@ processing :: forall m. MonadAff m => m Response
processing = processing' empty
-- | 102 with headers
processing' :: forall m. MonadAff m => Headers -> m Response
processing' :: forall m. MonadAff m => ResponseHeaders -> m Response
processing' = emptyResponse' Status.processing
---------
@ -293,7 +231,7 @@ ok :: forall m b. MonadAff m => Body b => b -> m Response
ok = ok' empty
-- | 200 with headers
ok' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
ok' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
ok' = response' Status.ok
-- | 201
@ -301,7 +239,7 @@ created :: forall m. MonadAff m => m Response
created = created' empty
-- | 201 with headers
created' :: forall m. MonadAff m => Headers -> m Response
created' :: forall m. MonadAff m => ResponseHeaders -> m Response
created' = emptyResponse' Status.created
-- | 202
@ -309,7 +247,7 @@ accepted :: forall m. MonadAff m => m Response
accepted = accepted' empty
-- | 202 with headers
accepted' :: forall m. MonadAff m => Headers -> m Response
accepted' :: forall m. MonadAff m => ResponseHeaders -> m Response
accepted' = emptyResponse' Status.accepted
-- | 203
@ -321,7 +259,7 @@ nonAuthoritativeInformation' ::
forall m b.
MonadAff m =>
Body b =>
Headers ->
ResponseHeaders ->
b ->
m Response
nonAuthoritativeInformation' = response' Status.nonAuthoritativeInformation
@ -331,7 +269,7 @@ noContent :: forall m. MonadAff m => m Response
noContent = noContent' empty
-- | 204 with headers
noContent' :: forall m. MonadAff m => Headers -> m Response
noContent' :: forall m. MonadAff m => ResponseHeaders -> m Response
noContent' = emptyResponse' Status.noContent
-- | 205
@ -339,7 +277,7 @@ resetContent :: forall m. MonadAff m => m Response
resetContent = resetContent' empty
-- | 205 with headers
resetContent' :: forall m. MonadAff m => Headers -> m Response
resetContent' :: forall m. MonadAff m => ResponseHeaders -> m Response
resetContent' = emptyResponse' Status.resetContent
-- | 206
@ -347,7 +285,7 @@ partialContent :: forall m b. MonadAff m => Body b => b -> m Response
partialContent = partialContent' empty
-- | 206 with headers
partialContent' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
partialContent' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
partialContent' = response' Status.partialContent
-- | 207
@ -355,7 +293,7 @@ multiStatus :: forall m b. MonadAff m => Body b => b -> m Response
multiStatus = multiStatus' empty
-- | 207 with headers
multiStatus' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
multiStatus' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
multiStatus' = response' Status.multiStatus
-- | 208
@ -363,7 +301,7 @@ alreadyReported :: forall m. MonadAff m => m Response
alreadyReported = alreadyReported' empty
-- | 208 with headers
alreadyReported' :: forall m. MonadAff m => Headers -> m Response
alreadyReported' :: forall m. MonadAff m => ResponseHeaders -> m Response
alreadyReported' = emptyResponse' Status.alreadyReported
-- | 226
@ -371,7 +309,7 @@ iMUsed :: forall m b. MonadAff m => Body b => b -> m Response
iMUsed = iMUsed' empty
-- | 226 with headers
iMUsed' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
iMUsed' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
iMUsed' = response' Status.iMUsed
---------
@ -382,7 +320,7 @@ multipleChoices :: forall m b. MonadAff m => Body b => b -> m Response
multipleChoices = multipleChoices' empty
-- | 300 with headers
multipleChoices' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
multipleChoices' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
multipleChoices' = response' Status.multipleChoices
-- | 301
@ -390,7 +328,7 @@ movedPermanently :: forall m b. MonadAff m => Body b => b -> m Response
movedPermanently = movedPermanently' empty
-- | 301 with headers
movedPermanently' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
movedPermanently' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
movedPermanently' = response' Status.movedPermanently
-- | 302
@ -398,7 +336,7 @@ found :: forall m b. MonadAff m => Body b => b -> m Response
found = found' empty
-- | 302 with headers
found' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
found' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
found' = response' Status.found
-- | 303
@ -406,7 +344,7 @@ seeOther :: forall m b. MonadAff m => Body b => b -> m Response
seeOther = seeOther' empty
-- | 303 with headers
seeOther' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
seeOther' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
seeOther' = response' Status.seeOther
-- | 304
@ -414,7 +352,7 @@ notModified :: forall m. MonadAff m => m Response
notModified = notModified' empty
-- | 304 with headers
notModified' :: forall m. MonadAff m => Headers -> m Response
notModified' :: forall m. MonadAff m => ResponseHeaders -> m Response
notModified' = emptyResponse' Status.notModified
-- | 305
@ -422,7 +360,7 @@ useProxy :: forall m b. MonadAff m => Body b => b -> m Response
useProxy = useProxy' empty
-- | 305 with headers
useProxy' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
useProxy' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
useProxy' = response' Status.useProxy
-- | 307
@ -430,7 +368,7 @@ temporaryRedirect :: forall m b. MonadAff m => Body b => b -> m Response
temporaryRedirect = temporaryRedirect' empty
-- | 307 with headers
temporaryRedirect' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
temporaryRedirect' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
temporaryRedirect' = response' Status.temporaryRedirect
-- | 308
@ -438,7 +376,7 @@ permanentRedirect :: forall m b. MonadAff m => Body b => b -> m Response
permanentRedirect = permanentRedirect' empty
-- | 308 with headers
permanentRedirect' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
permanentRedirect' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
permanentRedirect' = response' Status.permanentRedirect
---------
@ -449,7 +387,7 @@ badRequest :: forall m b. MonadAff m => Body b => b -> m Response
badRequest = badRequest' empty
-- | 400 with headers
badRequest' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
badRequest' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
badRequest' = response' Status.badRequest
-- | 401
@ -457,7 +395,7 @@ unauthorized :: forall m. MonadAff m => m Response
unauthorized = unauthorized' empty
-- | 401 with headers
unauthorized' :: forall m. MonadAff m => Headers -> m Response
unauthorized' :: forall m. MonadAff m => ResponseHeaders -> m Response
unauthorized' = emptyResponse' Status.unauthorized
-- | 402
@ -465,7 +403,7 @@ paymentRequired :: forall m. MonadAff m => m Response
paymentRequired = paymentRequired' empty
-- | 402 with headers
paymentRequired' :: forall m. MonadAff m => Headers -> m Response
paymentRequired' :: forall m. MonadAff m => ResponseHeaders -> m Response
paymentRequired' = emptyResponse' Status.paymentRequired
-- | 403
@ -473,7 +411,7 @@ forbidden :: forall m. MonadAff m => m Response
forbidden = forbidden' empty
-- | 403 with headers
forbidden' :: forall m. MonadAff m => Headers -> m Response
forbidden' :: forall m. MonadAff m => ResponseHeaders -> m Response
forbidden' = emptyResponse' Status.forbidden
-- | 404
@ -481,7 +419,7 @@ notFound :: forall m. MonadAff m => m Response
notFound = notFound' empty
-- | 404 with headers
notFound' :: forall m. MonadAff m => Headers -> m Response
notFound' :: forall m. MonadAff m => ResponseHeaders -> m Response
notFound' = emptyResponse' Status.notFound
-- | 405
@ -489,7 +427,7 @@ methodNotAllowed :: forall m. MonadAff m => m Response
methodNotAllowed = methodNotAllowed' empty
-- | 405 with headers
methodNotAllowed' :: forall m. MonadAff m => Headers -> m Response
methodNotAllowed' :: forall m. MonadAff m => ResponseHeaders -> m Response
methodNotAllowed' = emptyResponse' Status.methodNotAllowed
-- | 406
@ -497,7 +435,7 @@ notAcceptable :: forall m. MonadAff m => m Response
notAcceptable = notAcceptable' empty
-- | 406 with headers
notAcceptable' :: forall m. MonadAff m => Headers -> m Response
notAcceptable' :: forall m. MonadAff m => ResponseHeaders -> m Response
notAcceptable' = emptyResponse' Status.notAcceptable
-- | 407
@ -505,7 +443,7 @@ proxyAuthenticationRequired :: forall m. MonadAff m => m Response
proxyAuthenticationRequired = proxyAuthenticationRequired' empty
-- | 407 with headers
proxyAuthenticationRequired' :: forall m. MonadAff m => Headers -> m Response
proxyAuthenticationRequired' :: forall m. MonadAff m => ResponseHeaders -> m Response
proxyAuthenticationRequired' = emptyResponse' Status.proxyAuthenticationRequired
-- | 408
@ -513,7 +451,7 @@ requestTimeout :: forall m. MonadAff m => m Response
requestTimeout = requestTimeout' empty
-- | 408 with headers
requestTimeout' :: forall m. MonadAff m => Headers -> m Response
requestTimeout' :: forall m. MonadAff m => ResponseHeaders -> m Response
requestTimeout' = emptyResponse' Status.requestTimeout
-- | 409
@ -521,7 +459,7 @@ conflict :: forall m b. MonadAff m => Body b => b -> m Response
conflict = conflict' empty
-- | 409 with headers
conflict' :: forall m b. MonadAff m => Body b => Headers -> b -> m Response
conflict' :: forall m b. MonadAff m => Body b => ResponseHeaders -> b -> m Response
conflict' = response' Status.conflict
-- | 410
@ -529,7 +467,7 @@ gone :: forall m. MonadAff m => m Response
gone = gone' empty
-- | 410 with headers
gone' :: forall m. MonadAff m => Headers -> m Response
gone' :: forall m. MonadAff m => ResponseHeaders -> m Response
gone' = emptyResponse' Status.gone
-- | 411
@ -537,7 +475,7 @@ lengthRequired :: forall m. MonadAff m => m Response
lengthRequired = lengthRequired' empty
-- | 411 with headers
lengthRequired' :: forall m. MonadAff m => Headers -> m Response
lengthRequired' :: forall m. MonadAff m => ResponseHeaders -> m Response
lengthRequired' = emptyResponse' Status.lengthRequired
-- | 412
@ -545,7 +483,7 @@ preconditionFailed :: forall m. MonadAff m => m Response
preconditionFailed = preconditionFailed' empty
-- | 412 with headers
preconditionFailed' :: forall m. MonadAff m => Headers -> m Response
preconditionFailed' :: forall m. MonadAff m => ResponseHeaders -> m Response
preconditionFailed' = emptyResponse' Status.preconditionFailed
-- | 413
@ -553,7 +491,7 @@ payloadTooLarge :: forall m. MonadAff m => m Response
payloadTooLarge = payloadTooLarge' empty
-- | 413 with headers
payloadTooLarge' :: forall m. MonadAff m => Headers -> m Response
payloadTooLarge' :: forall m. MonadAff m => ResponseHeaders -> m Response
payloadTooLarge' = emptyResponse' Status.payloadTooLarge
-- | 414
@ -561,7 +499,7 @@ uRITooLong :: forall m. MonadAff m => m Response
uRITooLong = uRITooLong' empty
-- | 414 with headers
uRITooLong' :: forall m. MonadAff m => Headers -> m Response
uRITooLong' :: forall m. MonadAff m => ResponseHeaders -> m Response
uRITooLong' = emptyResponse' Status.uRITooLong
-- | 415
@ -569,7 +507,7 @@ unsupportedMediaType :: forall m. MonadAff m => m Response
unsupportedMediaType = unsupportedMediaType' empty
-- | 415 with headers
unsupportedMediaType' :: forall m. MonadAff m => Headers -> m Response
unsupportedMediaType' :: forall m. MonadAff m => ResponseHeaders -> m Response
unsupportedMediaType' = emptyResponse' Status.unsupportedMediaType
-- | 416
@ -577,7 +515,7 @@ rangeNotSatisfiable :: forall m. MonadAff m => m Response
rangeNotSatisfiable = rangeNotSatisfiable' empty
-- | 416 with headers
rangeNotSatisfiable' :: forall m. MonadAff m => Headers -> m Response
rangeNotSatisfiable' :: forall m. MonadAff m => ResponseHeaders -> m Response
rangeNotSatisfiable' = emptyResponse' Status.rangeNotSatisfiable
-- | 417
@ -585,7 +523,7 @@ expectationFailed :: forall m. MonadAff m => m Response
expectationFailed = expectationFailed' empty
-- | 417 with headers
expectationFailed' :: forall m. MonadAff m => Headers -> m Response
expectationFailed' :: forall m. MonadAff m => ResponseHeaders -> m Response
expectationFailed' = emptyResponse' Status.expectationFailed
-- | 418
@ -593,7 +531,7 @@ imATeapot :: forall m. MonadAff m => m Response
imATeapot = imATeapot' empty
-- | 418 with headers
imATeapot' :: forall m. MonadAff m => Headers -> m Response
imATeapot' :: forall m. MonadAff m => ResponseHeaders -> m Response
imATeapot' = emptyResponse' Status.imATeapot
-- | 421
@ -601,7 +539,7 @@ misdirectedRequest :: forall m. MonadAff m => m Response
misdirectedRequest = misdirectedRequest' empty
-- | 421 with headers
misdirectedRequest' :: forall m. MonadAff m => Headers -> m Response
misdirectedRequest' :: forall m. MonadAff m => ResponseHeaders -> m Response
misdirectedRequest' = emptyResponse' Status.misdirectedRequest
-- | 422
@ -609,7 +547,7 @@ unprocessableEntity :: forall m. MonadAff m => m Response
unprocessableEntity = unprocessableEntity' empty
-- | 422 with headers
unprocessableEntity' :: forall m. MonadAff m => Headers -> m Response
unprocessableEntity' :: forall m. MonadAff m => ResponseHeaders -> m Response
unprocessableEntity' = emptyResponse' Status.unprocessableEntity
-- | 423
@ -617,7 +555,7 @@ locked :: forall m. MonadAff m => m Response
locked = locked' empty
-- | 423 with headers
locked' :: forall m. MonadAff m => Headers -> m Response
locked' :: forall m. MonadAff m => ResponseHeaders -> m Response
locked' = emptyResponse' Status.locked
-- | 424
@ -625,7 +563,7 @@ failedDependency :: forall m. MonadAff m => m Response
failedDependency = failedDependency' empty
-- | 424 with headers
failedDependency' :: forall m. MonadAff m => Headers -> m Response
failedDependency' :: forall m. MonadAff m => ResponseHeaders -> m Response
failedDependency' = emptyResponse' Status.failedDependency
-- | 426
@ -633,7 +571,7 @@ upgradeRequired :: forall m. MonadAff m => m Response
upgradeRequired = upgradeRequired' empty
-- | 426 with headers
upgradeRequired' :: forall m. MonadAff m => Headers -> m Response
upgradeRequired' :: forall m. MonadAff m => ResponseHeaders -> m Response
upgradeRequired' = emptyResponse' Status.upgradeRequired
-- | 428
@ -641,7 +579,7 @@ preconditionRequired :: forall m. MonadAff m => m Response
preconditionRequired = preconditionRequired' empty
-- | 428 with headers
preconditionRequired' :: forall m. MonadAff m => Headers -> m Response
preconditionRequired' :: forall m. MonadAff m => ResponseHeaders -> m Response
preconditionRequired' = emptyResponse' Status.preconditionRequired
-- | 429
@ -649,7 +587,7 @@ tooManyRequests :: forall m. MonadAff m => m Response
tooManyRequests = tooManyRequests' empty
-- | 429 with headers
tooManyRequests' :: forall m. MonadAff m => Headers -> m Response
tooManyRequests' :: forall m. MonadAff m => ResponseHeaders -> m Response
tooManyRequests' = emptyResponse' Status.tooManyRequests
-- | 431
@ -657,7 +595,7 @@ requestHeaderFieldsTooLarge :: forall m. MonadAff m => m Response
requestHeaderFieldsTooLarge = requestHeaderFieldsTooLarge' empty
-- | 431 with headers
requestHeaderFieldsTooLarge' :: forall m. MonadAff m => Headers -> m Response
requestHeaderFieldsTooLarge' :: forall m. MonadAff m => ResponseHeaders -> m Response
requestHeaderFieldsTooLarge' = emptyResponse' Status.requestHeaderFieldsTooLarge
-- | 451
@ -665,7 +603,7 @@ unavailableForLegalReasons :: forall m. MonadAff m => m Response
unavailableForLegalReasons = unavailableForLegalReasons' empty
-- | 451 with headers
unavailableForLegalReasons' :: forall m. MonadAff m => Headers -> m Response
unavailableForLegalReasons' :: forall m. MonadAff m => ResponseHeaders -> m Response
unavailableForLegalReasons' = emptyResponse' Status.unavailableForLegalReasons
---------
@ -680,7 +618,7 @@ internalServerError' ::
forall m b.
MonadAff m =>
Body b =>
Headers ->
ResponseHeaders ->
b ->
m Response
internalServerError' = response' Status.internalServerError
@ -690,7 +628,7 @@ notImplemented :: forall m. MonadAff m => m Response
notImplemented = notImplemented' empty
-- | 501 with headers
notImplemented' :: forall m. MonadAff m => Headers -> m Response
notImplemented' :: forall m. MonadAff m => ResponseHeaders -> m Response
notImplemented' = emptyResponse' Status.notImplemented
-- | 502
@ -698,7 +636,7 @@ badGateway :: forall m. MonadAff m => m Response
badGateway = badGateway' empty
-- | 502 with headers
badGateway' :: forall m. MonadAff m => Headers -> m Response
badGateway' :: forall m. MonadAff m => ResponseHeaders -> m Response
badGateway' = emptyResponse' Status.badGateway
-- | 503
@ -706,7 +644,7 @@ serviceUnavailable :: forall m. MonadAff m => m Response
serviceUnavailable = serviceUnavailable' empty
-- | 503 with headers
serviceUnavailable' :: forall m. MonadAff m => Headers -> m Response
serviceUnavailable' :: forall m. MonadAff m => ResponseHeaders -> m Response
serviceUnavailable' = emptyResponse' Status.serviceUnavailable
-- | 504
@ -714,7 +652,7 @@ gatewayTimeout :: forall m. MonadAff m => m Response
gatewayTimeout = gatewayTimeout' empty
-- | 504 with headers
gatewayTimeout' :: forall m. MonadAff m => Headers -> m Response
gatewayTimeout' :: forall m. MonadAff m => ResponseHeaders -> m Response
gatewayTimeout' = emptyResponse' Status.gatewayTimeout
-- | 505
@ -722,7 +660,7 @@ hTTPVersionNotSupported :: forall m. MonadAff m => m Response
hTTPVersionNotSupported = hTTPVersionNotSupported' empty
-- | 505 with headers
hTTPVersionNotSupported' :: forall m. MonadAff m => Headers -> m Response
hTTPVersionNotSupported' :: forall m. MonadAff m => ResponseHeaders -> m Response
hTTPVersionNotSupported' = emptyResponse' Status.hTTPVersionNotSupported
-- | 506
@ -730,7 +668,7 @@ variantAlsoNegotiates :: forall m. MonadAff m => m Response
variantAlsoNegotiates = variantAlsoNegotiates' empty
-- | 506 with headers
variantAlsoNegotiates' :: forall m. MonadAff m => Headers -> m Response
variantAlsoNegotiates' :: forall m. MonadAff m => ResponseHeaders -> m Response
variantAlsoNegotiates' = emptyResponse' Status.variantAlsoNegotiates
-- | 507
@ -738,7 +676,7 @@ insufficientStorage :: forall m. MonadAff m => m Response
insufficientStorage = insufficientStorage' empty
-- | 507 with headers
insufficientStorage' :: forall m. MonadAff m => Headers -> m Response
insufficientStorage' :: forall m. MonadAff m => ResponseHeaders -> m Response
insufficientStorage' = emptyResponse' Status.insufficientStorage
-- | 508
@ -746,7 +684,7 @@ loopDetected :: forall m. MonadAff m => m Response
loopDetected = loopDetected' empty
-- | 508 with headers
loopDetected' :: forall m. MonadAff m => Headers -> m Response
loopDetected' :: forall m. MonadAff m => ResponseHeaders -> m Response
loopDetected' = emptyResponse' Status.loopDetected
-- | 510
@ -754,7 +692,7 @@ notExtended :: forall m. MonadAff m => m Response
notExtended = notExtended' empty
-- | 510 with headers
notExtended' :: forall m. MonadAff m => Headers -> m Response
notExtended' :: forall m. MonadAff m => ResponseHeaders -> m Response
notExtended' = emptyResponse' Status.notExtended
-- | 511
@ -762,5 +700,5 @@ networkAuthenticationRequired :: forall m. MonadAff m => m Response
networkAuthenticationRequired = networkAuthenticationRequired' empty
-- | 511 with headers
networkAuthenticationRequired' :: forall m. MonadAff m => Headers -> m Response
networkAuthenticationRequired' :: forall m. MonadAff m => ResponseHeaders -> m Response
networkAuthenticationRequired' = emptyResponse' Status.networkAuthenticationRequired