{      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                  ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk l m n o p q r s t u v w x y z { | } ~                                  None +2346:<BHLM+>Monadic analog to Read that uses ByteString instead of String.,Fails if the input wasn't parsed completely.+,+,+,+,None +2346:<BHLMneedle needle startneedle end (inclusive)haystackhaystack starthaystack end (inclusive)Bryan O'Sullivan 2008BSD3bos@serpentine.com experimentalunknownNone +2346:;<BHLMmThe lower bound on the size of a lookup table. We choose this to balance table density against performance. Create a set.Check the set for membership.zCheck the set for membership. Only works with 8-bit characters: characters above code point 255 will give wrong answers. None +2346:<BHLM-./0-./0-./0-./0None +2346:<BHLM123456789:;< 123456789:;< 123456789:;< 123456789:;<None +2346:<BHLM %Get the length of a bytestring StreamAEnumerates a Builder.BEnumerates a strict bytestring.CEnumerates a lazy bytestring.E Wraps an ., counting the number of bytes consumed by it.F#Creates a buffer to be passed into H.GEBuffers an iteratee, "unsafely". Here we use a fixed binary buffer which we'll re-use, meaning that if you hold on to any of the bytestring data passed into your iteratee (instead of, let's say, shoving it right out a socket) it'll get changed out from underneath you, breaking referential transparency. Use with caution!HEBuffers an iteratee, "unsafely". Here we use a fixed binary buffer which we'll re-use, meaning that if you hold on to any of the bytestring data passed into your iteratee (instead of, let's say, shoving it right out a socket) it'll get changed out from underneath you, breaking referential transparency. Use with caution!)This version accepts a buffer created by F.I5Skip n elements of the stream, if there are that manyJ5Skip n elements of the stream, if there are that manyLReads n bytes from a stream and applies the given iteratee to the stream of the read elements. Reads exactly n bytes, and if the stream is short propagates an error./=>?@ABCDEFGHIJKLMNOPQRSTUVaction to bump timeout'minimum data rate, in bytes per second3minimum amount of time to let the iteratee run foriteratee consumer to wrapE  !"#$%&'()*=>?@ABCDEFGHIJKLMNOPQRSTUVEBCANO=UEJFHGKILMDPQRSTV>@?" !&#$%(')*    +=>?@ABCDEFGHIJKLMNOPQRSTUVNone +2346:<BHLMWXYZWXYZXZYWWXYZNone +2346:<BHLMG[Represents an HTTP response.`We will need to inspect the content length no matter what, and looking up "content-length" in the headers and parsing the number out of the text will be too expensive.bReturns the HTTP status code.c+Returns the HTTP status explanation string.d4If true, we are transforming the request body with transformRequestBodyeControls whether Snap will buffer the output or not. You may wish to disable buffering when using Comet-like techniques which rely on the immediate sending of output data in order to maintain interactive semantics.gNoutput body is sendfile(), optional second argument is a byte range to sendhoutput body is a  enumeratori?Contains all of the information about an incoming HTTP request.kBThe server name of the request, as it came in from the request's Host: header.l8Returns the port number the HTTP server is listening on.mThe remote IP address.nThe remote TCP port number.o&The local IP address for this request.p8Returns the port number the HTTP server is listening on.q5Returns the HTTP server's idea of its local hostname.rReturns True if this is an HTTPS session.u Returns the Content-Length of the HTTP request body.v Returns the HTTP request method.w,Returns the HTTP version used by the client.xJReturns a list of the cookies that came in from the HTTP request headers.yHandlers can be hung on a URI^ "entry point"; this is called the "context path". If a handler is hung on the context path "/foo/", and you request  "/foo/bar", the value of y will be "bar".The following identity holds: rqURI r == S.concat [ rqContextPath r , rqPathInfo r , let q = rqQueryString r in if S.null q then "" else S.append "?" q ]z.The "context path" of the request; catenating z, and y% should get you back to the original { (ignoring query strings). The z' always begins and ends with a slash ("/"k) character, and represents the path (relative to your component/snaplet) you took to get to your handler.{ Returns the URI requested by the client.|'Returns the HTTP query string for this i.}(Returns the parameters mapping for this iJ. "Parameters" are automatically decoded from the URI's query string and POST* body and entered into this mapping. The } value is thus a union of ~ and .~:The parameter mapping decoded from the URI's query string.|The parameter mapping decoded from the POST body. Note that Snap only auto-decodes POST request bodies when the request's  Content-Type is !application/x-www-form-urlencoded. For multipart/form-data use  3 to decode the POST request and fill this mapping.@An existential wrapper for the 'Enumerator ByteString IO a' typeA type alias for the HTTP parameters mapping. Each parameter key maps to a list of ByteString values; if a parameter is specified multiple times (e.g.: "GET /foo?param=bar1&param=bar2"), looking up "param" in the mapping will give you ["bar1", "bar2"].'A datatype representing an HTTP cookie.The name of the cookie.The cookie's string value.-The cookie's expiration value, if it has one.+The cookie's "domain" value, if it has one.The cookie path.Tag as secure cookie? HttpOnly?(Enumerates the HTTP method values (see  5http://tools.ietf.org/html/rfc2068.html#section-5.1.1).5A typeclass for datatypes which contain HTTP headers.Modify the datatype's headers.6Retrieve the headers from a datatype that has headers.$Adds a header key-value-pair to the j datatype. If a header with the same name already exists, the new value is appended to the headers list."Sets a header key-value-pair in a ` datatype. If a header with the same name already exists, it is overwritten with the new value.*Gets all of the values for a given header.Gets a header value out of a X datatype. If many headers came in with the same name, they will be catenated together.Lists all the headers out of a X datatype. If many headers came in with the same name, they will be catenated together.Clears a header value from a  datatype.Looks up the value(s) for the given named parameter. Parameters initially come from the request's query string and any decoded POST body (if the request's  Content-Type is !application/x-www-form-urlencodedL). Parameter values can be modified within handlers using "rqModifyParams".TLooks up the value(s) for the given named parameter in the POST parameters mapping.ULooks up the value(s) for the given named parameter in the query parameters mapping.,Modifies the parameters mapping (which is a Map ByteString ByteString) in a i using the given function.LWrites a key-value pair to the parameters mapping within the given request. An empty [.(Sets an HTTP response body to the given ) value.=Sets the HTTP response status. Note: normally you would use 1 unless you needed a custom response explanation.Sets the HTTP response code.Modifies a response body. Sets the  Content-Type in the [ headers. Adds an HTTP  to [ headers. Gets an HTTP  with the given name from [ headers.Returns a list of  s present in [Deletes an HTTP  from the [Z headers. Please note this does not necessarily erase the cookie from the client browser.Modifies an HTTP  with given name in [- headers. Nothing will happen if a matching  can not be found in [.$A note here: if you want to set the Content-Lengtho 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.vIf you don't set a content length in your response, HTTP keep-alive will be disabled for HTTP/1.0 clients, forcing a Connection: closeO. For HTTP/1.1 clients, Snap will switch to the chunked transfer encoding if Content-Length is not specified. Removes any Content-Length set in the [.The buffering mode controls whether Snap will buffer the output or not. You may wish to disable buffering when using Comet-like techniques which rely on the immediate sending of output data in order to maintain interactive semantics.The buffering mode controls whether Snap will buffer the output or not. You may wish to disable buffering when using Comet-like techniques which rely on the immediate sending of output data in order to maintain interactive semantics. Converts a  into common log entry format. Converts a  into an HTTP timestamp."Converts an HTTP timestamp into a .l[\]^_`abcdefghijklmnopqrstuvwxyz{|}~parameter name to look up HTTP requestparameter name to look up HTTP requestparameter name to look up HTTP requestparameter nameparameter valuesrequestnew response body enumeratorresponse to modifyHTTP response integer codeHTTP response explanationResponse to be modifiedHTTP response integer codeResponse to be modified cookie valueresponse to modify cookie nameresponse to queryresponse to query cookie nameresponse to modify cookie namemodifier functionresponse to modify>if True, buffer the output, if False, send output immediatelyf[\]^_`abcdefghijklmnopqrstuvwxyz{|}~lijklmnopqrstuvwxyz{|}~fhg[\]^_`abcde5[ \]^_`abcdefhgijklmnopqrstuvwxyz{|}~ None +2346:;<BHLM 0Parsers for different tokens in an HTTP request.0Parsers for different tokens in an HTTP request.0Parsers for different tokens in an HTTP request.Parser for zero or more spaces.Parser for request headers.$Decodes an URL-escaped string (see  3http://tools.ietf.org/html/rfc2396.html#section-2.4)URL-escapes a string (see  3http://tools.ietf.org/html/rfc2396.html#section-2.4)URL-escapes a string (see  3http://tools.ietf.org/html/rfc2396.html#section-2.4 ) into a .Parses a string encoded in !application/x-www-form-urlencoded format.++++None +2346:<BHLMEGiven a Response, asserts that its HTTP status code is 200 (success).GGiven a Response, asserts that its HTTP status code is 404 (Not Found).Given a Response, asserts that its HTTP status code is between 300 and 399 (a redirect), and that the Location header of the Response points to the specified URI.YGiven a Response, asserts that its HTTP status code is between 300 and 399 (a redirect).NGiven a Response, asserts that its body matches the given regular expression.)The Response should redirect to this URI'Regexp that will match the body content None +2346:<BHLMPThis exception is thrown if the handler chooses to escape regular HTTP traffic.[An exception hierarchy for exceptions that cannot be caught by user-defined error handlerstimeout modifiersocket write end  None *+2346:<BHLM=6This exception is thrown if the handler you supply to 4 fails.   is the  that user web handlers run in.   gives you: +stateful access to fetch or modify an HTTP i+stateful access to fetch or modify an HTTP [ failure /  /  semantics: a  < handler can choose not to handle a given request, using  or its synonym 3, and you can try alternative handlers with the  operator: a :: Snap String a = pass b :: Snap String b = return "foo" c :: Snap String c = a <|> b -- try running a, if it fails then try b convenience functions (&, ', (, ), $+) for queueing output to be written to the [: a :: (forall a . Enumerator a) -> Snap () a someEnumerator = do writeBS "I'm a strict bytestring" writeLBS "I'm a lazy bytestring" writeText "I'm strict text" addToOutput someEnumerator early termination: if you call : a :: Snap () a = do modifyResponse $ setResponseStatus 500 "Internal Server Error" writeBS "500 error" r <- getResponse finishWith r<then any subsequent processing will be skipped and supplied [ value will be returned from 4 as-is. access to the  monad through a  instance: 'a :: Snap () a = liftIO fireTheMissiles Sthe ability to set or extend a timeout which will kill the handler thread after N3 seconds of inactivity (the default is 20 seconds): a :: Snap () a = setTimeout 30 #throw and catch exceptions using a  instance: `foo :: Snap () foo = bar `catch` \(e::SomeException) -> baz where bar = throw FooException log a message to the error log: (foo :: Snap () foo = logError "grumble."IYou may notice that most of the type signatures in this module contain a (MonadSnap m) => ... typeclass constraint.  A is a typeclass which, in essence, says "you can get back to the   monad from here". Using   you can extend the  J monad with additional functionality and still have access to most of the   functions without writing W everywhere. Instances are already provided for most of the common monad transformers (ReaderT, WriterT, , etc.).  is a type class, analogous to  for , that makes it easy to wrap   inside monad transformers.MThe Typeable instance is here so Snap can be dynamically executed with Hint. SSends the request body through an iteratee (data consumer) and returns the result.If the iteratee you pass in here throws an exception, Snap will attempt to clear the rest of the unread request body before rethrowing the exception. If your iteratee used 2?, however, Snap will give up and immediately close the socket. .Returns the request body as a lazy bytestring.This function is deprecated as of 0.6; it places no limits on the size of the request being read, and as such, if used, can result in a denial-of-service attack on your server. Please use  instead./Returns the request body as a lazy bytestring.  New in 0.6.xNormally Snap is careful to ensure that the request body is fully consumed after your web handler runs, but before the [ enumerator is streamed out the socket. If you want to transform the request body into some output in O(1) space, you should use this function.[Note that upon calling this function, response processing finishes early as if you called ]. Make sure you set any content types, headers, cookies, etc. before you call this function.Short-circuits a  ( monad action early, storing the given [ value in its state.4Capture the flow of control in case a handler calls .WARNING: in the event of a call to X it is possible to violate HTTP protocol safety when using this function. If you call 9 it is suggested that you do not modify the body of the [ which was passed to the  call.Fails out of a  t monad action. This is used to indicate that you choose not to handle the given request within the given handler.Runs a  J monad action only if the request's HTTP method matches the given method.Runs a  R monad action only if the request's HTTP method matches one of the given methods.Runs a   monad action only when the y9 of the request starts with the given path. For example, dir "foo" handler Will fail if y is not "/foo" or "/foo/...", and will add "foo/" to the handler's local z.Runs a  & monad action only for requests where yK is exactly equal to the given string. If the path matches, locally sets z to the old value of y, sets y!="", and runs the given handler.Runs a  z monad action only when the first path component is successfully parsed as the argument to the supplied handler function.Runs a   monad action only when y is empty.Local Snap version of .Local Snap monad version of . Grabs the i object out of the   monad.Grabs something out of the i3 object, using the given projection function. See . Grabs the [ object out of the   monad.Grabs something out of the [3 object, using the given projection function. See . Puts a new [ object into the   monad. Puts a new i object into the   monad. Modifies the i object stored in a   monad.  Modifes the [ object stored in a   monad.!#Performs a redirect by setting the LocationH header to the given target URL/path and the status code to 302 in the [ object stored in a  N monad. Note that the target URL is not validated in any way. Consider using  'redirect\''> instead, which allows you to choose the correct status code."#Performs a redirect by setting the Locationj header to the given target URL/path and the status code (should be one of 301, 302, 303 or 307) in the [ object stored in a  > monad. Note that the target URL is not validated in any way.#Log an error message in the   monad$1Adds the output from the given enumerator to the [ stored in the   monad state.%Adds the given  to the body of the [ stored in the |   monad state.&Adds the given strict  to the body of the [ stored in the   monad state.vWarning: This function is intentionally non-strict. If any pure exceptions are raised by the expression creating the B, the exception won't actually be raised within the Snap handler.'Adds the given lazy  to the body of the [ stored in the   monad state.vWarning: This function is intentionally non-strict. If any pure exceptions are raised by the expression creating the B, the exception won't actually be raised within the Snap handler.(Adds the given strict  to the body of the [ stored in the   monad state.vWarning: This function is intentionally non-strict. If any pure exceptions are raised by the expression creating the B, the exception won't actually be raised within the Snap handler.)Adds the given lazy  to the body of the [ stored in the   monad state.vWarning: This function is intentionally non-strict. If any pure exceptions are raised by the expression creating the B, the exception won't actually be raised within the Snap handler.*9Sets the output to be the contents of the specified file.Calling *5 will overwrite any output queued to be sent in the [:. If the response body is not modified after the call to *, Snap will use the efficient  sendfile()+ system call on platforms that support it.(If the response body is modified (using  ), the file will be read using mmap().+^Sets the output to be the contents of the specified file, within the given (start,end) range.Calling +5 will overwrite any output queued to be sent in the [:. If the response body is not modified after the call to +, Snap will use the efficient  sendfile()+ system call on platforms that support it.(If the response body is modified (using  ), the file will be read using mmap().,Runs a   action with a locally-modified i state object. The iR object in the Snap monad state after the call to localRequest will be unchanged.- Fetches the i- from state and hands it to the given action.. Fetches the [- from state and hands it to the given action./ Modifies the i in the state to set the mm field to the value in the X-Forwarded-For header. If the header is not present, this action has no effect.This action should be used only when working behind a reverse http proxy that sets the X-Forwarded-For header. This is the only way to ensure the value in the X-Forwarded-For header can be trusted.This is provided as a filter so actions that require the remote address can get it in a uniform manner. It has specifically limited functionality to ensure that its transformation can be trusted, when used correctly.0 Modifies the i in the state to set the mt field to the value from the header specified. If the header specified is not present, this action has no effect.This action should be used only when working behind a reverse http proxy that sets the header being looked at. This is the only way to ensure the value in the header can be trusted.This is provided as a filter so actions that require the remote address can get it in a uniform manner. It has specifically limited functionality to ensure that its transformation can be trusted, when used correctly.1sThis function brackets a Snap action in resource acquisition and release. This is provided because MonadCatchIO's h function doesn't work properly in the case of a short-circuit return from the action being bracketed.In order to prevent confusion regarding the effects of the aquisition and release actions on the Snap state, this function doesn't accept Snap actions for the acquire or release actions.This function will run the release action in all cases where the acquire action succeeded. This includes the following behaviors from the bracketed Snap action. Normal completion.Short-circuit completion, either from calling  or An exception being thrown.24Terminate the HTTP session with the given exception.3iTerminate the HTTP session and hand control to some external handler, escaping all further HTTP traffic.tThe external handler takes two arguments: a function to modify the thread's timeout, and a write end to the socket.4Runs a  ) monad action in the 'Iteratee IO' monad.'Post-process a finalized HTTP response:fixup content-length header!properly handle 204/304 responses)if request was HEAD, remove response bodyVNote that we do NOT deal with transfer-encoding: chunked or "connection: close" here.5See 9. Looks up a value for the given named parameter in the iD. If more than one value was entered for the given parameter name, 5 gloms the values together with:   " "6See Y. Looks up a value for the given named parameter in the POST form parameters mapping in iD. If more than one value was entered for the given parameter name, 6! gloms the values together with:   " "7See \. Looks up a value for the given named parameter in the query string parameters mapping in iD. If more than one value was entered for the given parameter name, 7! gloms the values together with:   " "8See }!. Convenience function to return  from the i inside of a   instance.9See }!. Convenience function to return  from the i inside of a   instance.:See }!. Convenience function to return  from the i inside of a   instance.;Gets the HTTP  with the specified name.<Gets the HTTP Y with the specified name and decodes it. If the decoding fails, the handler calls pass.=Expire the given  in client's browser.>'Causes the handler thread to be killed n seconds from now.?0Causes the handler thread to be killed at least n seconds from now.@CModifies the amount of time remaining before the request times out.A Returns an F action which you can use to set the handling thread's timeout value.B Returns an 6 action which you can use to modify the timeout value.`     nsize of the largest request body we're willing to accept. If a request body longer than this is received, a > is thrown. See M. the output  is passed to this ), and then the resulting ' is fed the request body stream. Your ), is responsible for transforming the input.path component to matchhandler to runpath to match againsthandler to run !"#$ output to add%&'()*+,-./012345parameter name to look up6parameter name to look up7parameter name to look up89:;<= Cookie name Cookie domain>?@AB     U      !"#$%&'()*+,-./0123456789:;<=>?@ABT      !"#$%&'()*+,-./0123456789:;<=>?@AB     None +2346:<BHLM  None +2346:<BHLMXThe internal data type you use to build a routing tree. Matching is done unambiguously. and  $ routes can have a "fallback" route:For 9, the fallback is routed when there is nothing to captureFor  >, the fallback is routed when we can't find a route in its map3Fallback routes are stacked: i.e. for a route like: 5Dir [("foo", Capture "bar" (Action bar) NoRoute)] bazvisiting the URI foo/ will result in the "bar" capture being empty and triggering its fallback. It's NoRoute, so we go to the nearest parent fallback and try that, which is the baz action.CA web handler which, given a mapping from URL entry points to web handlers, efficiently routes requests to the correct handler.>The URL entry points are given as relative paths, for example: &route [ ("foo/bar/quux", fooBarQuux) ]%If the URI of the incoming request is  /foo/bar/quuxor /foo/bar/quux/...anything...$then the request will be routed to " fooBarQuux", with z set to "/foo/bar/quux/" and y set to "...anything...".DA path component within an URL entry point beginning with a colon (":") is treated as a variable captureT; the corresponding path component within the request URI will be entered into the }K parameters mapping with the given name. For instance, if the routes were: )route [ ("foo/:bar/baz", fooBazHandler) ]Then a request for "/foo/saskatchewan/baz" would be routed to  fooBazHandler with a mapping for: "bar" => "saskatchewan"in its parameters table.kLonger paths are matched first, and specific routes are matched before captures. That is, if given routes: ([ ("a", h1), ("a/b", h2), ("a/:x", h3) ]a request for "/a/b " will go to h2, "/a/s " for any s will go to h3, and "/a " will go to h1.The following example matches "/article" to an article index, "/login" to a login, and " /article/..." to an article renderer. zroute [ ("article", renderIndex) , ("article/:id", renderArticle) , ("login", method POST doLogin) ] URL decodingQA short note about URL decoding: path matching and variable capture are done on decoded URLs, but the contents of z and ym will contain the original encoded URL, i.e. what the user entered. For example, in the following scenario: route [ ("a b c d/", foo ) ]A request for "/a+b+c+d" will be sent to foo with z set to "a+b+c+d".hThis behaviour changed as of Snap 0.6.1; previous versions had unspecified (and buggy!) semantics here.DThe D function is the same as !, except it doesn't change the request's context path. This is useful if you want to route to a particular handler but you want that handler to receive the y as it is. " #$%CD&'!-action to run before we call the user handler^the "context"; the list of path segments we've already successfully matched, in reverse order0the list of path segments we haven't yet matched( " #$%CD&'! # "$%CD&'!( None +2346:<BHLM)1[bciklmnoqruvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCD 4  123CD ,-.#  iklmnoqruvwxyz{|}~[bc1/0klmnoqruvwxyz{|}~56789:bc=;<!"$%&)('*+>?@AB)None +2346:<BHLM)1[bciklmnoqruvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDNone +2346:<BHLMEThe E datatype enumerates the different kinds of HTTP requests you can generate using the testing interface. Most users will prefer to use the _, a, b, c, and ` convenience functions.Mthe file's nameNthe file's content-typeOthe file contentsQ&a file upload consisting of the given K values.R(a form variable consisting of the given  values.SA request body of type "multipart/form-data" consists of a set of named form parameters, each of which can by either a list of regular form values or a set of file uploads.TTRequestBuilder is a monad transformer that allows you to conveniently build a snap i for testing.URuns a T, producing the desired i.N.B. please} don't use the request you get here in a real Snap application; things will probably break. Don't say you weren't warned :-)VSets the type of the i being built.WSets the request's query string to be the raw bytestring provided, without any escaping or other interpretation. Most users should instead choose the X+ function, which takes a parameter mapping.XOEscapes the given parameter mapping and sets it as the request's query string.YmSets the given header in the request being built, overwriting any header with the same name already present.Z1Adds the given header to the request being built.[Sets the request's  content-type to the given MIME type.\YControls whether the test request being generated appears to be an https request or not.]$Sets the test request's http version^>Sets the request's path. The path provided must begin with a "/ " and must notc contain a query string; if you want to provide a query string in your test request, you must use X or W . Note that z is never set by any T function._=Builds an HTTP "GET" request with the given query parameters.`@Builds an HTTP "DELETE" request with the given query parameters.awBuilds an HTTP "POST" request with the given form parameters, using the "application/x-www-form-urlencoded" MIME type.biBuilds an HTTP "POST" request with the given form parameters, using the "form-data/multipart" MIME type.cBuilds an HTTP "PUT" request.dPBuilds a "raw" HTTP "POST" request, with the given MIME type and body contents.eGiven a web handler in the   monad, and a T? defining a test request, runs the handler, producing an HTTP [.This function will produce almost exactly the same output as running the handler in a real server, except that chunked transfer encoding is not applied, and the "Transfer-Encoding" header is not set (this makes it easier to test response output).f&Given a web handler in some arbitrary  _ monad, a function specifying how to evaluate it within the context of the test monad, and a T? defining a test request, runs the handler, producing an HTTP [.gGiven a web handler in the   monad, and a TV defining a test request, runs the handler and returns the monadic value it produces.Throws an exception if the   handler early-terminates with  or ).h&Given a web handler in some arbitrary  _ monad, a function specifying how to evaluate it within the context of the test monad, and a TU defining a test request, runs the handler, returning the monadic value it produces.Throws an exception if the   handler early-terminates with  or ).i#Dumps the given response to stdout.j,Converts the given response to a bytestring.2EFGHIJKLMNOPQRST*+UV,-./012WXYZ[\]^_ request pathrequest's form parameters` request pathrequest's form parametersa request pathrequest's form parametersb request pathmultipart form parametersc request pathrequest body MIME content-typerequest body contentsd request pathrequest body MIME content-typerequest body contentsea request builder a web handlerfa function defining how the   monad should be runa request builder a web handlergha function defining how the   monad should be runa request builder a web handlerij345&EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij&EJIHGFKLMNOPRQST*+UV,-./012WXYZ[\]^_`abcdefghij345None +2346:<BHLM,EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij,TSPRQKLMNOEJIHGFUefgh_abcd`Z[Y]XW^V\ij None +2346:<BHLMkDA collection of options for serving static files out of a directory.mBFiles to look for when a directory is requested (e.g., index.html)n=Handler to generate a directory listing if there is no index.oMap of extensions to pass to dynamic file handlers. This could be used, for example, to implement CGI dispatch, pretty printing of source code, etc.p'MIME type map to look up content types.qHandler that is called before a file is served. It will only be called when a file is actually found, not for generated index pages.rA type alias for MIME types!A type alias for dynamic handlerstGets a path from the i using y and makes sure it is safe to use for opening files. A path is safe if it is a relative path and has no ".." elements to escape the intended directory structure.uLThe default set of mime type mappings we use when serving files. Its value:  Map.fromList [ ( ".asc" , "text/plain" ), ( ".asf" , "video/x-ms-asf" ), ( ".asx" , "video/x-ms-asf" ), ( ".avi" , "video/x-msvideo" ), ( ".bz2" , "application/x-bzip" ), ( ".c" , "text/plain" ), ( ".class" , "application/octet-stream" ), ( ".conf" , "text/plain" ), ( ".cpp" , "text/plain" ), ( ".css" , "text/css" ), ( ".cxx" , "text/plain" ), ( ".dtd" , "text/xml" ), ( ".dvi" , "application/x-dvi" ), ( ".gif" , "image/gif" ), ( ".gz" , "application/x-gzip" ), ( ".hs" , "text/plain" ), ( ".htm" , "text/html" ), ( ".html" , "text/html" ), ( ".ico" , "image/x-icon" ), ( ".jar" , "application/x-java-archive" ), ( ".jpeg" , "image/jpeg" ), ( ".jpg" , "image/jpeg" ), ( ".js" , "text/javascript" ), ( ".json" , "application/json" ), ( ".log" , "text/plain" ), ( ".m3u" , "audio/x-mpegurl" ), ( ".mov" , "video/quicktime" ), ( ".mp3" , "audio/mpeg" ), ( ".mpeg" , "video/mpeg" ), ( ".mpg" , "video/mpeg" ), ( ".ogg" , "application/ogg" ), ( ".pac" , "application/x-ns-proxy-autoconfig" ), ( ".pdf" , "application/pdf" ), ( ".png" , "image/png" ), ( ".ps" , "application/postscript" ), ( ".qt" , "video/quicktime" ), ( ".sig" , "application/pgp-signature" ), ( ".spl" , "application/futuresplash" ), ( ".svg" , "image/svg+xml" ), ( ".swf" , "application/x-shockwave-flash" ), ( ".tar" , "application/x-tar" ), ( ".tar.bz2" , "application/x-bzip-compressed-tar" ), ( ".tar.gz" , "application/x-tgz" ), ( ".tbz" , "application/x-bzip-compressed-tar" ), ( ".text" , "text/plain" ), ( ".tgz" , "application/x-tgz" ), ( ".torrent" , "application/x-bittorrent" ), ( ".txt" , "text/plain" ), ( ".wav" , "audio/x-wav" ), ( ".wax" , "audio/x-ms-wax" ), ( ".wma" , "audio/x-ms-wma" ), ( ".wmv" , "video/x-ms-wmv" ), ( ".xbm" , "image/x-xbitmap" ), ( ".xml" , "text/xml" ), ( ".xpm" , "image/x-xpixmap" ), ( ".xwd" , "image/x-xwindowdump" ), ( ".zip" , "application/zip" ) ]6<Style information for the default directory index generator.vAn automatic index generator, which is fairly small and does not rely on any external files (which may not be there depending on external request routing).A r is passed in to display the types of files in the directory listing based on their extension. Preferably, this is the same as the map in the k The styles parameter allows you to apply styles to the directory listing. The listing itself consists of a table, containing a header row using th elements, and one row per file using td elements, so styles for those pieces may be attached to the appropriate tags.wfA very simple configuration for directory serving. This configuration uses built-in MIME types from uF, and has no index files, index generator, dynamic file handlers, or q.xmA reasonable default configuration for directory serving. This configuration uses built-in MIME types from u, serves common index files  index.html and  index.htmX, but does not autogenerate directory indexes, nor have any dynamic file handlers. The q will not do anything.ydA more elaborate configuration for file serving. This configuration uses built-in MIME types from u, serves common index files  index.html and  index.htmj, and autogenerates directory indexes with a Snap-like feel. It still has no dynamic file handlers, nor q#, which should be added as needed.$Files recognized as indexes include  index.html,  index.htm,  default.html,  default.htm,  home.htmlzRServes static files from a directory using the default configuration as given in x.{NServes static files from a directory. Configuration options are passed in a kT that captures various choices about desired behavior. The relative path given in y is searched for a requested file, and the file is served with the appropriate mime type if it is found. Absolute paths and "..N" are prohibited to prevent files from being served from outside the sandbox.|Serves a single file specified by a full or relative path. If the file does not exist, throws an exception (not that it does not8 pass to the next handler). The path restrictions on zP don't apply to this function since the path is not being supplied by the user.}Same as |*, with control over the MIME mapping used."789:;<klmnopqrstu6v%MIME type mapping for reporting typesStyle info to insert in headerDirectory to generate index forwxyzDirectory to serve from{Configuration optionsDirectory to serve from| path to file} MIME type path to file=~>?@ABCklmnopqrstuvwxyz{|}~trsklmnopqwxyvu~z{|}7:8;<9klmnopqrstu6vwxyz{|}=~>?@ABC None +2346:<BHLMDThis is the file which is currently being written to. If the calling function gets an exception here, it is responsible for closing and deleting this file.EB.. and these files have already been successfully read and closed.6Upload policy can be set on an "general" basis (using ), but handlers can also make policy decisions on individual files/parts uploaded. For each part uploaded, handlers can decide:'whether to allow the file upload at all.the maximum size of uploaded files, if allowed0 controls overall policy decisions relating to multipart/form-data uploads, specifically:Qwhether to treat parts without filenames as form input (reading them into the } map)because form input is read into memory, the maximum size of a form input read in this manner, and the maximum number of form inputsthe minimum upload rate a client must maintain before we kill the connection; if very low-bitrate uploads were allowed then a Snap server would be vulnerable to a trivial denial-of-service using a "slowloris"-type attackuthe minimum number of seconds which must elapse before we start killing uploads for having too low an upload rate.pthe amount of time we should wait before timing out the connection whenever we receive input from the client.<All of the exceptions defined in this package inherit from , so if you write .foo `catch` \(e :: FileUploadException) -> ...you can catch a , a , etc.A contains information about a "part" in a request uploaded with !Content-type: multipart/form-data.ZReads uploaded files into a temporary directory and calls a user handler to process them.Given a temporary directory, global and file-specific upload policies, and a user handler, this function consumes a request body uploaded with !Content-type: multipart/form-data. Each file is read into the temporary directory, and then a list of the uploaded files is passed to the user handler. After the user handler runs (but before the [ body ) is streamed to the client), the files are deleted from disk; so if you want to retain or use the uploaded files in the generated response, you would need to move or otherwise process them.5The argument passed to the user handler is a list of: 4(PartInfo, Either PolicyViolationException FilePath)"The first half of this tuple is a , which contains the information the client browser sent about the given upload part (like filename, content-type, etc). The second half of this tuple is an F stipulating that either: Dthe file was rejected on a policy basis because of the provided  handler3the file was accepted and exists at the given path.If the request's  Content-type was not "multipart/formdata)", this function skips processing using .FIf the client's upload rate passes below the configured minimum (see  and ), this function terminates the connection. This setting is there to protect the server against slowloris-style denial of service attacks. If the given ; stipulates that you wish form inputs to be placed in the } parameter map (using U), and a form input exceeds the maximum allowable size, this function will throw a .If an uploaded part contains MIME headers longer than a fixed internal threshold (currently 32KB), this function will throw a .iGiven an upload policy and a function to consume uploaded "parts", consume a request body uploaded with !Content-type: multipart/form-data(. Normally most users will want to use  (which writes uploaded files to a temporary directory and passes their names to a given handler) rather than this function; the lower-level ^ function should be used if you want to stream uploaded files to your own iteratee function.If the request's  Content-type was not "multipart/formdata)", this function skips processing using .FIf the client's upload rate passes below the configured minimum (see  and ), this function terminates the connection. This setting is there to protect the server against slowloris-style denial of service attacks. If the given ; stipulates that you wish form inputs to be placed in the } parameter map (using U), and a form input exceeds the maximum allowable size, this function will throw a .If an uploaded part contains MIME headers longer than a fixed internal threshold (currently 32KB), this function will throw a .FA reasonable set of defaults for upload policy. The default policy is: maximum form input size128kBmaximum number of form inputs10minimum upload rate1kB/s%seconds before rate limiting kicks in10inactivity timeout 20 seconds_Does this upload policy stipulate that we want to treat parts without filenames as form input?ISet the upload policy for treating parts without filenames as form input.DGet the maximum size of a form input which will be read into our } map.DSet the maximum size of a form input which will be read into our } map.DGet the maximum size of a form input which will be read into our } map.DSet the maximum size of a form input which will be read into our } map.Get the minimum rate (in  bytes/second:) a client must maintain before we kill the connection.Set the minimum rate (in  bytes/second:) a client must maintain before we kill the connection.]Get the amount of time which must elapse before we begin enforcing the upload rate minimum]Set the amount of time which must elapse before we begin enforcing the upload rate minimumGet the "upload timeout". Whenever input is received from the client, the connection timeout is set this many seconds in the future.Set the upload timeout."Disallows the file to be uploaded.2Allows the file to be uploaded, with maximum size n.GGiven a  stream which is partitioned by boundary values, read up until the next boundary and send all of the chunks into the wrapped iterateeH>Assuming we've already identified the boundary value and run T to split the input up into parts which match and parts which don't, run the given B iteratee over each part and grab a list of the resulting values.RIJKLDEMNOPQRSTUVWXYZ[\]^_temporary directorygeneral upload policyper-part upload policy(user handler (see function description)global upload policypart processor`abmaximum size of form inputfile reading codecdboundary valuepart processorefgGHhijklmnopqrstuvwx 6IJKLDEMONPQRSTUVWXYZ^[_\]`abcdefgGHhijklmnopqrstuvwx None +2346:<BHLMRuns a  + web handler with compression if available.(If the client has indicated support for gzip or deflate in its Accept-Encoding header, and the  Content-Type0 in the response is one of the following types: application/x-javascript application/json text/css  text/html text/javascript  text/plain text/xml application/x-font-truetype<Then the given handler's output stream will be compressed, Content-Encoding- will be set in the output headers, and the Content-Lengtho will be cleared if it was set. (We can't process the stream in O(1) space if the length is known beforehand.)<The wrapped handler will be run to completion, and then the [ that's contained within the   monad state will be passed to  to prevent further processing. The same as 2, with control over which MIME types to compress.VTurn off compression by setting "Content-Encoding: identity" in the response headers.yzthe web handler to runset of compressible MIME typesthe web handler to run{|}~buffer?buffer? yz{|}~None +2346:<BHLM2What kind of proxy is this? Affects which headers ) pulls the original remote address from.'Currently only proxy servers that send X-Forwarded-For or  Forwarded-For are supported.Use the  Forwarded-For or X-Forwarded-For header!no proxy, leave the request aloneRewrite m if we're behind a proxy. !"#$%&'()*+*,*-*./0/1/23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwwxyz{|}~                     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^^_`abcdefghijklmnUopqrstuvwx y y z { | } ~                                              TXYZ[\Nn       !"#$%&'()*+,-./0123456789:;<=>f?@ABCDEFGHI J K L M K N O P Q R S T U V W XYZ [ \ ] ] ^ ^ 4 _ 4  `  a b c d e f   g h i j k l m n o p q r s t u v w x y z { | } ~                 snap-core-0.9.7.0 Snap.IterateeSnap.Util.ReadableSnap.Internal.DebugSnap.Types.HeadersSnap.Internal.Iteratee.DebugSnap.Internal.Http.TypesSnap.Internal.Parsing Snap.TestSnap.Internal.Exceptions Snap.CoreSnap.Util.FileServeSnap.Util.FileUploadsSnap.Util.GZipSnap.Util.Proxy)Snap.Internal.Iteratee.BoyerMooreHorspoolSnap.Internal.Parsing.FastSethandleFileUploadsSnap.Internal.Test.AssertionsSnap.Internal.TypesSnap.Internal.InstancesSnap.Internal.Routing Snap.Types!Snap.Internal.Test.RequestBuilderenumerator-0.4.20Data.Enumerator catchError throwErrorData.Enumerator.InternalIterateepeek liftTransisEOFsequence$==$joinI concatEnumsenumList printChunksrun_runData.Enumerator.Compatibility liftFoldM liftFoldL' liftFoldLliftIData.Enumerator.Listheadconsumemap checkDoneenumEOF<==<>==>$$==<<>>==continueyieldreturnIChunksEOFStreamContinueYieldErrorStep runIteratee Enumerator EnumerateeReadablefromBSdebug debugErrno debugIgnoredebugErrnoIgnoreHeadersemptynullmemberlookuplookupWithDefaultinsertsetdeletefoldtoListfromListInvalidRangeExceptionTooManyBytesReadExceptionRateTooSlowExceptionShortWriteException enumBuilderenumBSenumLBS skipToEof countBytesmkIterateeBufferunsafeBufferIterateeunsafeBufferIterateeWithBufferdropdrop'take takeExactlytakeNoMoreThanenumFileenumFilePartialmapEnummapIterenumBuilderToByteStringunsafeEnumBuilderToByteStringenumByteStringToBuilderjoinI' killIfTooSlow showBuilder debugIterateeiterateeDebugWrapperWithiterateeDebugWrapperResponse rspHeaders rspCookiesrspHttpVersionrspContentLengthrspBody rspStatusrspStatusReasonrspTransformingRqBodyrspOutputBuffering ResponseBodySendFileEnumRequest rqServerName rqServerPort rqRemoteAddr rqRemotePort rqLocalAddr rqLocalPortrqLocalHostname rqIsSecure rqHeadersrqBodyrqContentLengthrqMethod rqVersion rqCookies rqPathInfo rqContextPathrqURI rqQueryStringrqParams rqQueryParams rqPostParamsSomeEnumeratorParamsCookie cookieName cookieValue cookieExpires cookieDomain cookiePath cookieSecurecookieHttpOnly HttpVersionMethodPATCHCONNECTOPTIONSTRACEDELETEPUTPOSTHEADGET HasHeaders updateHeadersheadersc_format_log_timec_format_http_timec_parse_http_time set_c_locale addHeader setHeader getHeaders getHeader listHeaders deleteHeader rspBodyMap rspBodyToEnumrqParam rqPostParam rqQueryParamrqModifyParams rqSetParam emptyResponsesetResponseBodysetResponseStatussetResponseCodemodifyResponseBodysetContentTypeaddResponseCookiegetResponseCookiegetResponseCookiesdeleteResponseCookiemodifyResponseCookiesetContentLengthclearContentLengthgetBufferingModesetBufferingMode formatLogTimeformatHttpTime parseHttpTimefromStrtoStrstatusReasonMap$fHasHeadersResponse$fShowResponse$fHasHeadersHeaders$fHasHeadersRequest $fShowRequest $fEqMethodDList fullyParseparseNumspdigitletteruntilEOLcrlf generateFSspacespSpaces fieldChars fieldCharSetpHeaderspWord pQuotedString isRFCTextmatchAllpAvPairspAvPair pParametertrimpValueWithParameterspContentTypeWithParameterspTokenisToken tokenTableparseToCompletion pUrlEscaped urlDecode urlEncodeurlEncodeBuilderurlEncodeTablehexdfinishparseUrlEncodedbuildUrlEncodedprintUrlEncodedpCookies parseCookie strictize unsafeFromHex unsafeFromIntgetResponseBody assertSuccess assert404assertRedirectToassertRedirectassertBodyContainsEscapeHttpHandlerEscapeHttpExceptionConnectionTerminatedExceptionUncatchableExceptionuncatchableExceptionToException!uncatchableExceptionFromException$fExceptionEscapeHttpException$fShowEscapeHttpException($fExceptionConnectionTerminatedException#$fShowConnectionTerminatedException$fExceptionUncatchableException$fShowUncatchableExceptionNoHandlerExceptionSnap MonadSnapliftSnaprunRequestBodygetRequestBodyreadRequestBodytransformRequestBody finishWithcatchFinishWithpassmethodmethodsdirpathpathArgifTop getRequest getsRequest getResponse getsResponse putResponse putRequest modifyRequestmodifyResponseredirect redirect'logError addToOutput writeBuilderwriteBSwriteLBS writeText writeLazyTextsendFilesendFilePartial localRequest withRequest withResponseipHeaderFilteripHeaderFilter' bracketSnapterminateConnection escapeHttprunSnapgetParam getPostParam getQueryParam getParams getPostParamsgetQueryParams getCookie readCookie expireCookie setTimeout extendTimeout modifyTimeoutgetTimeoutActiongetTimeoutModifierroute routeLocal RequestType DeleteRequestUrlEncodedPostRequestMultipartPostRequestRequestWithRawBody GetRequestFileData fdFileName fdContentType fdContentsMultipartParamFilesFormDataMultipartParamsRequestBuilder buildRequestsetRequestTypesetQueryStringRawsetQueryString setSecuresetHttpVersionsetRequestPathgetpostUrlEncoded postMultipartputpostRaw runHandler runHandlerM evalHandler evalHandlerM dumpResponseresponseToStringDirectoryConfig indexFilesindexGeneratordynamicHandlers mimeTypes preServeHookMimeMap HandlerMap getSafePathdefaultMimeTypesdefaultIndexGeneratorsimpleDirectoryConfigdefaultDirectoryConfigfancyDirectoryConfigserveDirectoryserveDirectoryWith serveFile serveFileAsfileTypePartUploadPolicy UploadPolicyPolicyViolationExceptionpolicyViolationExceptionReasonBadPartExceptionbadPartExceptionReasonFileUploadExceptionPartInfo partFieldName partFileNamepartContentTypehandleMultipartfileUploadExceptionReasondefaultUploadPolicydoProcessFormInputssetProcessFormInputsgetMaximumFormInputSizesetMaximumFormInputSizegetMaximumNumberOfFormInputssetMaximumNumberOfFormInputsgetMinimumUploadRatesetMinimumUploadRategetMinimumUploadSecondssetMinimumUploadSecondsgetUploadTimeoutsetUploadTimeoutdisallowallowWithMaximumSizewithCompressionwithCompression' noCompression ProxyTypeX_Forwarded_ForNoProxy behindProxy checkComplete$fReadableDouble$fReadableInteger $fReadableInt$fReadableText$fReadableByteString MatchInfoNoMatchMatch lookaheadmatches bmhEnumeratee tableCutoff memberWord8 memberCharIFastSetTableSortedfromSetshiftRshiftLindexmkTable charClass $fShowFastSetHunH streamLengthbUFSIZtake' _enumFile_enumFilePartialmaxMMapFileSize tooBigForMMapgetTime $fExceptionInvalidRangeException$fShowInvalidRangeException$$fExceptionTooManyBytesReadException$fExceptionRateTooSlowException$fExceptionShortWriteException$fShowTooManyBytesReadException$fShowRateTooSlowException$fShowShortWriteException$fMonadCatchIOIterateebytestring-0.10.4.0 Data.ByteString.Builder.InternalBuilderbaseForeign.C.TypesCTimeGHC.BaseMonadControl.Applicative Alternative Control.Monad MonadPlus<|>ghc-prim GHC.TypesIOtransformers-0.3.0.0Control.Monad.IO.ClassMonadIO!MonadCatchIO-transformers-0.3.1.3Control.Monad.CatchIO MonadCatchIOControl.Monad.Trans.ClassliftControl.Monad.Trans.State.LazyStateT snapTyConsget mtl-2.1.3.1Control.Monad.State.ClasssmodifymodifygetsData.ByteString.Internal ByteStringData.ByteString.Lazy.Internal text-1.2.0.4Data.Text.InternalTextData.Text.Internal.Lazybracketfail fixupResponseData.ByteString intercalate SnapState _snapRequest _snapResponse _snapLogError_snapModifyTimeoutunSnap SnapResultEarlyTerminationPassOnProcessing SnapValuesnapBind snapReturnsnapFailrethrowIfUncatchableliftIterupdateContextPathpathWithevalSnap getParamFrom$fExceptionNoHandlerException$fShowNoHandlerException$fMonadSnapSnap$fAlternativeSnap$fApplicativeSnap $fFunctorSnap$fMonadError[]Snap$fMonadPlusSnap$fMonadCatchIOSnap $fMonadIOSnap $fMonadSnap$fMonadSnapWriterT$fMonadSnapWriterT0$fMonadSnapStateT$fMonadSnapStateT0$fMonadSnapReaderT$fMonadSnapRWST$fMonadSnapRWST0$fMonadSnapListT$fMonadSnapErrorT$fMonadSnapContT$fAlternativeContT$fMonadPlusContTRouteCaptureDirroute'NoRouteAction routeHeightrouteEarliestNC splitPathpRoute $fMonoidRoutemzeromkDefaultRequest makeBoundarymultipartHeaderencodeFormDatamultipartMixed encodeFilesencodeMultipartfixupURIrGetrPutrModifysnapIndexStylesRangeReqSuffixRangeReq _suffixLength _rangeFirst _rangeLast lookupExtdefaultMimeType rangeParser checkRangeReqdbguriWithoutQueryStringqueryStringSuffix _currentFile_alreadyReadFiles Data.EitherEither processPart processParts UploadedFilesUploadedFilesStateFile_maximumFileSizeprocessFormInputsmaximumFormInputSizemaximumNumberOfFormInputsminimumUploadRateminimumUploadSeconds uploadTimeoutWrappedFileUploadException_wrappedFileUploadException!_wrappedFileUploadExceptionReasonGenericFileUploadException!_genericFileUploadExceptionReasonuploadExceptionToExceptionuploadExceptionFromExceptioncaptureVariableOrReadFile fileReaderinternalHandleMultipartgetContentType getFieldName findParameolpHeadersWithSeparator toHeaders mAX_HDRS_SIZEemptyUploadedFilesStatenewUploadedFilescleanupUploadedFilesopenFileForUploadcloseActiveFile eatException makeTempFile$fShowPolicyViolationException#$fExceptionPolicyViolationException$fShowBadPartException$fExceptionBadPartException$fExceptionFileUploadException$fShowFileUploadExceptionBadAcceptEncodingExceptioncompressibleMimeTypesgzipCompressioncompressCompression gcompress ccompress acceptParserparseAcceptEncoding%$fExceptionBadAcceptEncodingException $fShowBadAcceptEncodingException xForwardedFor