Hoogle Search
Within LTS Haskell 24.46 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
setHeader :: HasHeaders a => CI ByteString -> ByteString -> a -> asnap-core Snap.Internal.Http.Types Sets a header key-value-pair in a HasHeaders datatype. If a header with the same name already exists, it is overwritten with the new value. Example:
ghci> import qualified Snap.Types.Headers as H ghci> setHeader "Host" "localhost" H.empty H {unH = [("host","localhost")]} ghci> setHeader "Host" "127.0.0.1" it H {unH = [("host","127.0.0.1")]}
setResponseBody :: (OutputStream Builder -> IO (OutputStream Builder)) -> Response -> Responsesnap-core Snap.Internal.Http.Types Sets an HTTP response body to the given stream procedure. Example:
ghci> :set -XOverloadedStrings ghci> import qualified System.IO.Streams as Streams ghci> import qualified Data.ByteString.Builder as Builder ghci> :{ ghci| let r = setResponseBody ghci| (out -> do ghci| Streams.write (Just $ Builder.byteString "Hello, world!") out ghci| return out) ghci| emptyResponse ghci| :} ghci> r HTTP/1.1 200 OK Hello, world!
setResponseCode :: Int -> Response -> Responsesnap-core Snap.Internal.Http.Types Sets the HTTP response code. Example:
ghci> setResponseCode 404 emptyResponse HTTP/1.1 404 Not Found
setResponseStatus :: Int -> ByteString -> Response -> Responsesnap-core Snap.Internal.Http.Types Sets the HTTP response status. Note: normally you would use setResponseCode unless you needed a custom response explanation. Example:
ghci> :set -XOverloadedStrings ghci> setResponseStatus 500 "Internal Server Error" emptyResponse HTTP/1.1 500 Internal Server Error
-
snap-core Snap.Internal.Http.Types No documentation available.
setContentType :: forall (m :: Type -> Type) . Monad m => ByteString -> RequestBuilder m ()snap-core Snap.Test Sets the request's content-type to the given MIME type. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> buildRequest $ put "/foo/bar" "text/html" "some text" >> setContentType "text/plain" PUT /foo/bar HTTP/1.1 content-type: text/plain content-length: 9 host: localhost sn="localhost" c=127.0.0.1:60000 s=127.0.0.1:8080 ctx=/ clen=9
-
snap-core Snap.Test Sets the given header in the request being built, overwriting any header with the same name already present. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> :{ ghci| buildRequest $ do get "/foo/bar" M.empty ghci| setHeader "Accept" "text/html" ghci| setHeader "Accept" "text/plain" ghci| :} GET /foo/bar HTTP/1.1 accept: text/plain host: localhost sn="localhost" c=127.0.0.1:60000 s=127.0.0.1:8080 ctx=/ clen=n/a
setHttpVersion :: forall (m :: Type -> Type) . Monad m => (Int, Int) -> RequestBuilder m ()snap-core Snap.Test Sets the test request's http version Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> buildRequest $ delete "/foo/bar" M.empty >> setHttpVersion (1,0) DELETE /foo/bar HTTP/1.0 host: localhost sn="localhost" c=127.0.0.1:60000 s=127.0.0.1:8080 ctx=/ clen=n/a
setQueryString :: forall (m :: Type -> Type) . Monad m => Params -> RequestBuilder m ()snap-core Snap.Test Escapes the given parameter mapping and sets it as the request's query string. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> buildRequest $ get "/foo/bar" M.empty >> setQueryString (M.fromList [("param0", ["baz"]), ("param1", ["qux"])]) GET /foo/bar?param0=baz¶m1=qux HTTP/1.1 host: localhost sn="localhost" c=127.0.0.1:60000 s=127.0.0.1:8080 ctx=/ clen=n/a params: param0: ["baz"], param1: ["qux"]
setQueryStringRaw :: forall (m :: Type -> Type) . Monad m => ByteString -> RequestBuilder m ()snap-core Snap.Test Sets the request's query string to be the raw bytestring provided, without any escaping or other interpretation. Most users should instead choose the setQueryString function, which takes a parameter mapping. Example:
ghci> :set -XOverloadedStrings ghci> import qualified Data.Map as M ghci> buildRequest $ get "/foo/bar" M.empty >> setQueryStringRaw "param0=baz¶m1=qux" GET /foo/bar?param0=baz¶m1=qux HTTP/1.1 host: localhost sn="localhost" c=127.0.0.1:60000 s=127.0.0.1:8080 ctx=/ clen=n/a params: param0: ["baz"], param1: ["qux"]