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.
setTimeout :: MonadSnap m => Int -> m ()snap-core Snap.Core Causes the handler thread to be killed n seconds from now.
setContentLength :: Word64 -> Response -> Responsesnap-core Snap.Internal.Core A note here: if you want to set the Content-Length for the response, Snap forces you to do it with this function rather than by setting it in the headers; the Content-Length in the headers will be ignored. The reason for this is that Snap needs to look up the value of Content-Length for each request, and looking the string value up in the headers and parsing the number out of the text will be too expensive. If you don't set a content length in your response, HTTP keep-alive will be disabled for HTTP/1.0 clients, forcing a Connection: close. For HTTP/1.1 clients, Snap will switch to the chunked transfer encoding if Content-Length is not specified. Example:
ghci> setContentLength 400 emptyResponse HTTP/1.1 200 OK Content-Length: 400
setContentType :: ByteString -> Response -> Responsesnap-core Snap.Internal.Core Sets the Content-Type in the Response headers. Example:
ghci> :set -XOverloadedStrings ghci> setContentType "text/html" emptyResponse HTTP/1.1 200 OK content-type: text/html
setHeader :: HasHeaders a => CI ByteString -> ByteString -> a -> asnap-core Snap.Internal.Core 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.Core 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.Core Sets the HTTP response code. Example:
ghci> setResponseCode 404 emptyResponse HTTP/1.1 404 Not Found
setResponseStatus :: Int -> ByteString -> Response -> Responsesnap-core Snap.Internal.Core 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
setTimeout :: MonadSnap m => Int -> m ()snap-core Snap.Internal.Core Causes the handler thread to be killed n seconds from now.
setContentLength :: Word64 -> Response -> Responsesnap-core Snap.Internal.Http.Types A note here: if you want to set the Content-Length for the response, Snap forces you to do it with this function rather than by setting it in the headers; the Content-Length in the headers will be ignored. The reason for this is that Snap needs to look up the value of Content-Length for each request, and looking the string value up in the headers and parsing the number out of the text will be too expensive. If you don't set a content length in your response, HTTP keep-alive will be disabled for HTTP/1.0 clients, forcing a Connection: close. For HTTP/1.1 clients, Snap will switch to the chunked transfer encoding if Content-Length is not specified. Example:
ghci> setContentLength 400 emptyResponse HTTP/1.1 200 OK Content-Length: 400
setContentType :: ByteString -> Response -> Responsesnap-core Snap.Internal.Http.Types Sets the Content-Type in the Response headers. Example:
ghci> :set -XOverloadedStrings ghci> setContentType "text/html" emptyResponse HTTP/1.1 200 OK content-type: text/html