1 {-|
    2 
    3 This module contains the core type definitions, class instances, and functions
    4 for HTTP as well as the 'Snap' monad, which is used for web handlers.
    5 
    6 -}
    7 module Snap.Core
    8   (
    9     -- * The Snap Monad
   10     Snap
   11   , runSnap
   12   , MonadSnap(..)
   13   , NoHandlerException(..)
   14 
   15     -- ** Functions for control flow and early termination
   16   , bracketSnap
   17   , finishWith
   18   , catchFinishWith
   19   , pass
   20 
   21     -- *** Escaping HTTP
   22   , EscapeHttpHandler
   23   , EscapeSnap(..)
   24   , escapeHttp
   25   , terminateConnection
   26 
   27     -- ** Routing
   28   , method
   29   , methods
   30   , path
   31   , pathArg
   32   , dir
   33   , ifTop
   34   , route
   35   , routeLocal
   36 
   37     -- ** Access to state
   38   , getRequest
   39   , getsRequest
   40   , getResponse
   41   , getsResponse
   42   , putRequest
   43   , putResponse
   44   , modifyRequest
   45   , modifyResponse
   46   , localRequest
   47   , withRequest
   48   , withResponse
   49 
   50     -- ** Logging
   51   , logError
   52 
   53     -- ** Grabbing/transforming request bodies
   54   , runRequestBody
   55   , readRequestBody
   56   , transformRequestBody
   57 
   58     -- * HTTP Datatypes and Functions
   59     -- $httpDoc
   60     --
   61   , Request
   62   , Response
   63   , Headers
   64   , HasHeaders(..)
   65   , Params
   66   , Method(..)
   67   , Cookie(..)
   68   , HttpVersion
   69 
   70     -- ** Headers
   71   , addHeader
   72   , setHeader
   73   , getHeader
   74   , listHeaders
   75   , deleteHeader
   76   , ipHeaderFilter
   77   , ipHeaderFilter'
   78 
   79     -- ** Requests
   80   , rqHeaders
   81   , rqHostName
   82   , rqClientAddr
   83   , rqClientPort
   84   , rqServerAddr
   85   , rqServerPort
   86   , rqLocalHostname
   87   , rqIsSecure
   88   , rqContentLength
   89   , rqMethod
   90   , rqVersion
   91   , rqCookies
   92   , rqPathInfo
   93   , rqContextPath
   94   , rqURI
   95   , rqQueryString
   96   , rqParams
   97   , rqQueryParams
   98   , rqPostParams
   99   , rqParam
  100   , rqPostParam
  101   , rqQueryParam
  102   , getParam
  103   , getPostParam
  104   , getQueryParam
  105   , getParams
  106   , getPostParams
  107   , getQueryParams
  108   , rqModifyParams
  109   , rqSetParam
  110 
  111     -- *** Deprecated functions
  112   , rqRemoteAddr
  113   , rqRemotePort
  114 
  115     -- ** Responses
  116   , emptyResponse
  117   , setResponseCode
  118   , setResponseStatus
  119   , rspStatus
  120   , rspStatusReason
  121   , setContentType
  122   , addResponseCookie
  123   , getResponseCookie
  124   , getResponseCookies
  125   , deleteResponseCookie
  126   , modifyResponseCookie
  127   , expireCookie
  128   , getCookie
  129   , readCookie
  130   , setContentLength
  131   , clearContentLength
  132   , redirect
  133   , redirect'
  134 
  135     -- *** Response I/O
  136   , setResponseBody
  137   , modifyResponseBody
  138   , addToOutput
  139   , writeBuilder
  140   , writeBS
  141   , writeLazyText
  142   , writeText
  143   , writeLBS
  144   , sendFile
  145   , sendFilePartial
  146 
  147     -- ** Timeouts
  148   , setTimeout
  149   , extendTimeout
  150   , modifyTimeout
  151   , getTimeoutModifier
  152 
  153     -- * HTTP utilities
  154   , formatHttpTime
  155   , parseHttpTime
  156   , parseUrlEncoded
  157   , buildUrlEncoded
  158   , printUrlEncoded
  159   , urlEncode
  160   , urlEncodeBuilder
  161   , urlDecode
  162   ) where
  163 
  164 ------------------------------------------------------------------------------
  165 import           Snap.Internal.Core       (EscapeHttpHandler, EscapeSnap (..), MonadSnap (..), NoHandlerException (..), Snap, addToOutput, bracketSnap, catchFinishWith, dir, escapeHttp, expireCookie, extendTimeout, finishWith, getCookie, getParam, getParams, getPostParam, getPostParams, getQueryParam, getQueryParams, getRequest, getResponse, getTimeoutModifier, getsRequest, getsResponse, ifTop, ipHeaderFilter, ipHeaderFilter', localRequest, logError, method, methods, modifyRequest, modifyResponse, modifyTimeout, pass, path, pathArg, putRequest, putResponse, readCookie, readRequestBody, redirect, redirect', runRequestBody, runSnap, sendFile, sendFilePartial, setTimeout, terminateConnection, transformRequestBody, withRequest, withResponse, writeBS, writeBuilder, writeLBS, writeLazyText, writeText)
  166 import           Snap.Internal.Http.Types (Cookie (..), HasHeaders (..), HttpVersion, Method (..), Params, Request (rqClientAddr, rqClientPort, rqContentLength, rqContextPath, rqCookies, rqHeaders, rqHostName, rqIsSecure, rqLocalHostname, rqMethod, rqParams, rqPathInfo, rqPostParams, rqQueryParams, rqQueryString, rqServerAddr, rqServerPort, rqURI, rqVersion), Response (rspStatus, rspStatusReason), addHeader, addResponseCookie, clearContentLength, deleteHeader, deleteResponseCookie, emptyResponse, formatHttpTime, getHeader, getResponseCookie, getResponseCookies, listHeaders, modifyResponseBody, modifyResponseCookie, parseHttpTime, rqModifyParams, rqParam, rqPostParam, rqQueryParam, rqRemoteAddr, rqRemotePort, rqSetParam, setContentLength, setContentType, setHeader, setResponseBody, setResponseCode, setResponseStatus)
  167 import           Snap.Internal.Instances  ()
  168 import           Snap.Internal.Parsing    (buildUrlEncoded, parseUrlEncoded, printUrlEncoded, urlDecode, urlEncode, urlEncodeBuilder)
  169 import           Snap.Internal.Routing    (route, routeLocal)
  170 import           Snap.Types.Headers       (Headers)
  171 ------------------------------------------------------------------------------
  172 
  173 -- $httpDoc
  174 -- HTTP-related datatypes: 'Request', 'Response', 'Cookie', etc.