|h_      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                  ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 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 [ \ ] ^  ___`Ealternative implementation of accept to work around EAI_AGAIN errors ``abcdefghiacdefgacdefg jklmnopqrstjjportable experimental lemmih@vo.com)uvwxA MIME media type value.  The y$ instance is derived automatically.  Use z to obtain the standard  string representation.  See  #http://www.ietf.org/rfc/rfc2046.txt for more ' information about MIME media types. +The top-level media type, the general type $ of the data. Common examples are  "text", "image", "audio", "video",  " multipart", and " application". -The media subtype, the specific data format.  Examples include "plain", "html",  "jpeg", " form-data", etc. ,Media type parameters. On common example is ! the charset parameter for the "text"  top-level type, e.g. ("charset"," ISO-8859-1"). {|}~z>Produce the standard string representation of a content-type,  e.g. "text/html; charset=ISO-8859-1". 5Parse the standard representation of a content-type. 6 If the input cannot be parsed, this function calls  / with a (hopefully) informative error message. RFC 822 LWSP-char #RFC 822 CRLF (but more permissive)  One line uvwx{|}~zuvvwxx{|}~znon-portable (not tested) experimentalbjorn@bringert.netAllows stream logging.  Refer to  below. ?Streams should make layering of TLS protocol easier in future,  they allow reading/$writing to files etc for debugging, + they allow use of protocols other than TCP/IP  and they allow customisation. (Instances of this class should not trim - the input in any way, e.g. leave LF on line 3 endings etc. Unless that is exactly the behaviour ) you want from your twisted instances ;) >This is the type returned by many exported network functions. Wraps a stream with logging I/ O, the first 7 argument is a filename which is opened in AppendMode. non-portable (not tested) experimentalbjorn@bringert.net The 4 object allows input buffering, and maintenance of  some admin-type data. The - newtype is a wrapper that allows us to make ( connections an instance of the StreamIn/%Out classes, without ghc extensions. D While this looks sort of like a generic reference to the transport = layer it is actually TCP specific, which can be seen in the  implementation of the 'Stream Connection' instance. /Open a connection to port 80 on a remote host. 3This function establishes a connection to a remote  host, it uses  getHostByName which interrogates the 5 DNS system, hence may trigger a network connection. Add a  persistant) option? Current persistant is default.  Use Result+ type for synchronous exception reporting? 4Checks both that the underlying Socket is connected 0 and that the connection peer matches the given ( host name (which is recorded locally).  non-portable (not tested) experimentalbjorn@bringert.net{An HTTP Response.  The y: instance of this type is used for message serialisation, B which means no body data is output, additionally the output will D show an HTTP version of 1.1 instead of the actual version returned  by a server. An HTTP Request.  The y: instance of this type is used for message serialisation, % which means no body data is output. might need changing in future  1) to support  uri in OPTIONS request + 2) transparent support for both relative  &% absolute uris, although this should  already work (leave scheme & host parts empty). +The HTTP request method, to be used in the  object. = We are missing a few of the stranger methods, but these are - not really necessary until we add full TLS. DThis class allows us to write generic header manipulation functions  for both  and  data types. HTTP Header Name type: 0 Why include this at all? I have some reasons / 1) prevent spelling errors of header names, 5 2) remind everyone of what headers are available, 4 3) might speed up searches for specific headers. Arguments against: / 1) makes customising header names laborious  2) increases code volume. 1Allows for unrecognised or experimental headers.      (The Header data type pairs header names & values. 0Inserts a header with the given name and value.  Allows duplicate header names. 6Adds the new header only if no previous header shares  the same name. )Removes old headers with duplicate name. Inserts multiple headers. )Gets a list of headers with a particular . <Lookup presence of specific HeaderName in a list of Headers 3 Returns the value from the first matching header.  !"#$%&'(ASimple way to get a resource across a non-persistant connection.  Headers that may be altered: > Host Altered only if no Host header is supplied, HTTP/1.1 & requires a Host header. D Connection Where no allowance is made for persistant connections 3 the Connection header will be set to close )Like (*, but acting on an already opened stream. *2this is not the most graceful of implementations. . The problem is that Network.URI.authority is 6 deprecated. And we want to use Network.URI.URIAuth. So this method use to parse a host field as a URI 0 auth, which is not stictly correct. We still  fake that behavior here. +,-HReceive and parse a HTTP request from the given Stream. Should be used ! for server side interactions. .HVery simple function, send a HTTP response over the given stream. This 9 could be improved on to use different transfer types. /4Used when we know exactly how many bytes to expect. 0'Used when nothing about data is known, . Unfortunately waiting for a socket closure ' causes bad behaviour. Here we just ( take data once and give up the rest. 1A necessary feature of HTTP/1.1 , Also the only transfer variety likely to  return any footers. 232Maybe in the future we will have a sensible thing 4 to do here, at that time we might want to change  the name. 4DRemove leading crlfs then call readTillEmpty2 (not required by RFC) 5'Read lines until an empty line (CRLF), - also accepts a connection close as end of  input, which is not an HTTP/1.1 compliant * thing to do - so probably indicates an  error condition. 678w     !()+,-.678Z2          !()+,-.678-  !"#$%&'()*+,-./01-  !"#$%&'()*+,-./01.   !"#$%&'(  )*+,-./01-   !"#$%&'()*+,-./01 9:;<=>?@AB9>?@AB9>?@AB non-portable experimental lemmih@vo.comCDEFG!Read a multi-part message from a H.  Boundary I!Read a multi-part message from a J.  Fails on parse errors.  Boundary KL4Split a multipart message into the multipart parts. )The boundary, without the initial dashes M=Drop everything up to and including the first line starting  with the boundary. Returns N if there is no " line starting with a boundary. )The boundary, without the initial dashes O+Split a string at the first boundary line. )The boundary, without the initial dashes String to split. 1The part before the boundary, the boundary line, 2 and the part after the boundary line. The CRLF 8 before and the CRLF (if any) after the boundary line 4 are not included in any of the strings returned.  Returns N if there is no boundary. P:Check whether a string starts with two dashes followed by  the given boundary string. )The boundary, without the initial dashes Q!Check whether a string for which P returns true , has two dashes after the boudary string. )The boundary, without the initial dashes R0Checks whether a string starts with two dashes. S4Drop everything up to and including the first CRLF. TESplit a string at the first empty line. The CRLF (if any) before the B empty line is included in the first result. The CRLF after the - empty line is not included in the result.  N( is returned if there is no empty line. U;Split a string at the first CRLF. The CRLF is not included # in any of the returned strings. String to split. Returns N if there is no CRLF. VLike U%, but if no CRLF is found, the first B result is the argument string, and the second result is empty. W4Get the index and length of the first CRLF, if any. String to split. XYZ7Drop an initial CRLF, if any. If the string is empty, < nothing is done. If the string does not start with CRLF, # the first character is dropped. uvwx{CDEFGILTU CDDEFFGILTU2344Convenience class for converting data types to URIs 56789*Retrieves the path component from the URI :+Retrieves the query component from the URI ;,Retrieves the scheme component from the URI <EModifies the scheme component of the URI using the provided function =CModifies the path component of the URI using the provided function >%Sets the scheme component of the URI ?#Sets the path component of the URI @AB$Returns true if the URI is absolute C/Render should be used for prettyprinting URIs. D9Parses a URI from a String. Returns Nothing on failure. 23456789:;<=>?@ABCD9:;<=>?@AB678CD4523233455678789:;<=>?@ABCDEFGHIJKLM9Creates a cookie with a default version of 1 and path of / NSet a Cookie in the Result. ? The values are escaped as per RFC 2109, but some browsers may 0 have buggy support for cookies containing e.g. '"' or ' '. AAlso, it seems that chrome, safari, and other webkit browsers do A not like cookies which have double quotes around the domain and  reject/6ignore the cookie. So, we no longer quote the domain. [O9Not an supported api. Takes a cookie header and returns = either a String error message or an array of parsed cookies P4not a supported api. A parser for RFC 2109 cookies QLGet all cookies from the HTTP request. The cookies are ordered per RFC from I the most specific to the least specific. Multiple cookies with the same  name are allowed to exist. RLGet the most specific cookie with the given name. Fails if there is no such F cookie or if the browser did not escape cookies in a proper fashion. @ Browser support for escaping cookies properly is very diverse. ST\EFGHIJKLMNOPQRSTEFGHIJKLMNQRSTOPEFGHIJKLFGHIJKLMNOPQRSTXUV]^_WXYZ[\]^_`abcdefghijklmnopqrst Result flags uv=whether a content-length header will be added to the result. wCombined headers. xyz{|HTTP request method }~HTTP configuration "Port for the server to listen on.  HTTP version `a?Should the connection be used for further messages after this.  | isHTTP1_0 && hasKeepAlive || isHTTP1_1 && hasNotConnectionClose HDefault configuration contains no validator and the port is set to 8000 <Default RsFlags that will include the content-length header Don')t display a Content-Lenght field for the Result. DConverts a Request into a String representing the corresponding URL LSets the Response status code to the provided Int and lifts the computation  into a Monad. CTakes a list of (key,val) pairs and converts it into Headers. The % keys will be converted to lowercase .Lookup header value. Key is case-insensitive. ;Lookup header value. Key is a case-insensitive bytestring. JLookup header value with a case-sensitive key. The key must be lowercase. bDLookup header with a case-sensitive key. The key must be lowercase. HReturns True if the associated key is found in the Headers. The lookup  is case insensitive. Acts as  with ByteStrings Acts as . but the key is case sensitive. It should be  in lowercase. cdAssociates the key/1value pair in the headers. Forces the key to be  lowercase. Acts as  but with ByteStrings. ISets the key to the HeaderPair. This is the only way to associate a key L with multiple values via the setHeader* functions. Does not force the key _ to be in lowercase or guarantee that the given key and the key in the HeaderPair will match.  Add a key/:value pair to the header. If the key already has a value 8 associated with it, then the value will be appended. ! Forces the key to be lowercase. )Acts as addHeader except for ByteStrings  Add a key/>value pair to the header using the underlying HeaderPair data } type. Does not force the key to be in lowercase or guarantee that the given key and the key in the HeaderPair will match. JCreates a Response with the given Int as the status code and the provided % String as the body of the Response Acts as & but works with ByteStrings directly. Sets the Response'>s status code to the given Int and redirects to the given URI efghQUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~UWXYZ[\]^_`abchdijklmijkmefgUVopqrsxyz{tuv|~}wnLUVVW XYZ[\]^_`abXYZ[\]^_`abchdijklmijkmefgdefghijklmnopqrspqrstuvuvwxyz{yz{|~}}~ Like i& except Strings and Chars not quoted. Decodes application/$x-www-form-urlencoded inputs. Decodes multipart/form-data input. Content-type parameters  Request body Input variables and values. %Packs a string into an Input of type  text/plain (The default content-type for variables. 'Get the path components from a String. &jklmn=Unserializes the bytestring into a response. If there is an  error it will return Left msg. opqrstuvwx+Serializes the request to the given handle yz{|}~Bind and listen port &Use a previously bind port and listen WUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~@Sends the serialized request to the host defined in the request . and attempts to parse response upon arrival. Uses  to transform the given XML   into a  a . DPerforms an XSL transformation with lists of ByteStrings instead of  a String. Equivalent to 4 but does not hide the inherent IO of the low-level  ByteString operations. :Uses the provided xsl file to transform the given string. A This function creates temporary files during its execution, but  guarantees their cleanup. .Note that the xsl file must have .xsl suffix. Use xsltproc to transform XML. Use saxon to transform XML.   requires mtl provisional lemmih@vo.comNUsed to convert arbitrary types into an HTTP response. You need to implement  this if you want to pass  ServerPartT m containing your type into . Minimal definition: .  Useful for   and getData'( implement this on your preferred type  to use those functions. This class is used by ) to parse a path component into a value. C At present, the instances for number types (Int, Float, etc) just  call . The instance for  however, just passes the A path component straight through. This is so that you can read a + path component which looks like this as a : / somestring/ 6instead of requiring the path component to look like: /" somestring"/ A control structure. ) It ends the computation and returns the hc you passed into it G immediately. This provides an alternate escape route. In particular : it has a monadic value of any type. And unless you call  id 7 first your response filters will be applied normally. Extremely useful when you'+re deep inside a monad and decide that you C want to return a completely different content type, since it doesn't / force you to convert all your return types to hc early just to  accomodate this. 1It is worth discussing the unpacked structure of  a bit as it' s exposed  in  and . A fully unpacked " has a structure that looks like:  J ununWebT $ WebT m a :: m (Maybe (Either Response a, FilterFun Response))  So, ignoring m, as it is just the containing , the outermost layer is  a  . This is N if  was called or  ( hc  a,  ( hc)) if  wasn't called. Inside the , J there is a pair. The second element of the pair is our filter function   hc.  hc is a type alias for   ( ( hc)) . This is just a wrapper for a hc -> hc  function with a particular  behavior. The value   Append (Dual (Endo f)) 2Causes f to be composed with the previous filter.   Set (Dual (Endo f)) 6Causes f to not be composed with the previous filter. 1Finally, the first element of the pair is either  Left Response or Right a. AAnother way of looking at all these pieces is from the behaviors  they control. The  controls the  behavior. Set  (Endo f) comes from the  behavior. Likewise, Append  (Endo f) is from .  Left Response is what you  get when you call  and Right a is the normal exit. &An example case statement looks like:  ex1 webt = do  val <- ununWebT webt  case val of N Nothing -> Nothing -- this is the interior value when mzero was used a Just (Left r, f) -> Just (Left r, f) -- r is the value that was passed into "finishWith" I -- f is our filter function P Just (Right a, f) -> Just (Right a, f) -- a is our normal monadic value Q -- f is still our filter function $The basic response building object. 0A set of functions for manipulating filters. A  implements   hc. so these methods are the fundamental ways of 8 manipulating the response object, especially before you've converted your  monadic value to a hc. 0Ignores all previous alterations to your filter As an example:   do  composeFilter f  setFilter g  return "Hello World" >setFilter g will cause the first composeFilter to be ignored. 7Composes your filter function with the existing filter  function. *Retrives the filter from the environment.  FilterFun is a lot more fun to type than SetAppend (Dual (Endo a)). A monoid operation container.  If a is a monoid, then + is a monoid with the following behaviors:  7 Set x `mappend` Append y = Set (x `mappend` y) 7 Append x `mappend` Append y = Append (x `mappend` y) & _ `mappend` Set y = Set y :A simple way of summarizing this is, if the right side is Append , then the 6 right is appended to the left. If the right side is Set, then the left side  is ignored. Yes, this is exactly like  with new names.  Why you ask? Because ServerT can lift up a . ) If you did that, it would shadow ServerT' s behavior 6 as a ReaderT, thus meaning if you lifted the ReaderT  you could no longer modify the XW . This way  you can add a  to your monad stack without  any trouble. JServerPartT is a container for processing requests and returning results. 2An alias for using ServerPartT when using the IO. !An alias for WebT when using IO. :particularly useful when combined with runWebT to produce  a m (Maybe Response) from a request. GUsed to manipulate the containing monad. Very useful when embedding a  monad into a , since  requires a ServerPartT IO a.  Refer to 3 for an explanation of the structure of the monad. 2Here is an example. Suppose you want to embed an  into your   to enable  and  in your .  7 type MyServerPartT e m a = ServerPartT (ErrorT e m) a Now suppose you want to pass  MyServerPartT into a function  that demands a ServerPartT IO a (e.g. ). You  can provide the function:  L unpackErrorT :: (Monad m, Show e) => UnWebT (ErrorT e m) a -> UnWebT m a  unpackErrorT et = do  eitherV <- runErrorT et  return $ case eitherV of T Left err -> Just (Left $ toResponse $ "Catastrophic failure " ++ show err H , Set $ Dual $ Endo $ \r -> r{rsCode = 500})  Right x -> x With  unpackErrorT you can now call . Just wrap your  ServerPartT list.  T simpleHTTP nullConf $ mapServerPartT unpackErrorT (myPart `catchError` myHandler) Or alternatively:  D simpleHTTP' unpackErrorT nullConf (myPart `catchError` myHandler)  Also see 64 for a more sophisticated version of this function.  A variant of 0 where the first argument also takes a request.  Useful if you want to  on a different  inside your  monad (see 6). $Extract the value from a SetAppend. 5 Note that a SetAppend is actually a CoPointed from:   hhttp://hackage.haskell.org/packages/archive/category-extras/latest/doc/html/Control-Functor-Pointed.html . But lets not drag in that dependency. yet... Deprecated: use .  Takes your  , if it is  it returns N else it  converts the value to a hc and applies your filter to it. %For when you really need to unpack a  entirely (and not " just unwrap the first layer with ). For wrapping a  back up. mkWebT . ununWebT = id See $ for a discussion of this function.  An alias for  setFilter id It resets all your filters. 8Used to ignore all your filters and immediately end the  computation. A combination of  and . An alternate form of % that can be easily used within a do  block.  An array of , useful for processing  command line options into an  for . "Parse command line options into a . =Use the built-in web-server to serve requests according to a  . Use * to pick the first handler from a list of  handlers that doesn't call . This function always binds o ? IPv4 ports until Network module is fixed to support IPv6 in a  portable way. Use  with custom socket if you  want different behaviour. A combination of  and . See  0 for a discussion of the first argument of this B function. This function always binds to IPv4 ports until Network 8 module is fixed to support IPv6 in a portable way. Use  * with custom socket if you want different  behaviour. Generate a result from a  and a XW. This is mainly used ! by CGI (and fast-cgi) wrappers. Run ; with a previously bound socket. Useful if you want to run 8 happstack as user on port 80. Use something like this:  J import System.Posix.User (setUserID, UserEntry(..), getUserEntryForName)   main = do ' let conf = nullConf { port = 80 }  socket <- bindPort conf $ -- do other stuff as root here 6 getUserEntryForName "www" >>= setUserID . userID 1 -- finally start handling incoming requests ; tid <- forkIO $ simpleHTTPWithSocket socket conf impl Note: It'As important to use the same conf (or at least the same port) for   and . Like  with a socket. $Bind port and return the socket for . This F function always binds to IPv4 ports until Network module is fixed to ! support IPv6 in a portable way. low-level function to build a hc from a content-type and a   ByteString  Creates a hc in a manner similar to the  class, 1 but with out requiring an instance declaration.  content-type response body  turns your arbitrary m a and converts it too  a m hc with . 'This is kinda like a very oddly shaped  or  . You probably want one or the other of those. !Get a header out of the request. Add headers into the response. 9 This method does not overwrite any existing header of ! the same name, hence the name  . If you  want to replace a header use . 3Set a header into the response. This will replace + an existing header of the same name. Use  if you 4 want to add more than one header of the same name. 2Guard using an arbitrary function on the request. <Guard against the method. This function also guards against " any remaining path segments. See  for the version  that guards only by method .Guard against the method only. (as opposed to ) FGuard against the method. Note, this function also guards against any  remaining path segments. FGuard against the method. Note, this function also guards against any J remaining path segments. This function is deprecated. You can probably % just use methodSP (or methodM) now. 1Guard against non-empty remaining path segments. Pop a path element and run the ! if it matches the given string. !The path element can not contain '/' . See also . Guard against a  . Unlike  the  may  contain '/'6. If the guard succeeds, the matched elements will be " popped from the directory stack.   dirs "foo/bar" $ ...  See also: . Guard against the host. 3Lookup the host header and pass it to the handler. *Pop a path element and parse it using the  in the  class. GGrab the rest of the URL (dirs + query) and passes it to your handler. /Pop any path element and ignore when chosing a  to  handle the request.  Deprecated: use .  0Guard which checks that the Request URI ends in '/'. # Useful for distinguishing between foo and foo/  Parse your request with a  (a ReaderT, basically)  For example here is a simple GET or POST variable based authentication % guard. It handles the request with  errorHandler if authentication fails.  myRqData = do & username <- lookInput "username" & password <- lookInput "password" ! return (username, password)  checkAuth errorHandler = do  d <- getData myRqDataA  case d of ! Nothing -> errorHandler % Just a | isValid a -> mzero , Just a | otherwise -> errorHandler  An variant of   that uses  to chose your   for you. The example from   becomes:  myRqData = do & username <- lookInput "username" & password <- lookInput "password" ! return (username, password) * instance FromData (String,String) where  fromData = myRqData  checkAuth errorHandler = do  d <- getData'  case d of ! Nothing -> errorHandler % Just a | isValid a -> mzero , Just a | otherwise -> errorHandler  3Retrieve data from the input query or the cookies.  is like  , but you pass in a  monad  for reading.  is for creating s that proxy.  The sole argument [String]" is a list of allowed domains for 8 proxying. This matches the domain part of the request & and the wildcard * can be used. E.g.  "*" to match anything.  " *.example.com"% to match anything under example.com  " example.com" to match just example.com ATODO: annoyingly enough, this method eventually calls escape, so  any headers you set won'0t be used, and the computation immediatly ends. Takes a proxy XW and creates a hc. Your basic proxy  building block. See . *TODO: this would be more useful if it didn't call  (e.g. it let you < modify the response afterwards, or set additional headers) (This is a reverse proxy implementation.  See . *TODO: this would be more useful if it didn't call  , just like  proxyServe'.  defaultHost 9map to look up hostname mappings. For the reverse proxy =the result is a ServerPartT that will reverse proxy for you. $Run an IO action and, if it returns Just", pass it to the second argument. =A variant of require that can run in any monad, not just IO. Use cmd to transform XML against xslPath. 2 This function only acts if the content-type is  application/xml. XSLT preprocessor. Usually xsltproc or saxon. Path to xslt stylesheet.  Affected  ServerParts. /Add the cookie with a timeout to the response. 6Add the list of cookie timeout pairs to the response. Expire the cookie immediately.  Honor an if-modified-since header in a XW.  If the XW includes the if-modified-since header and the  hc8 has not been modified, then return 304 (Not Modified),  otherwise return the hc. 8mod-time for the Response (MUST NOT be later than server's time of message origination) 7incoming request (used to check for if-modified-since) ,Response to send if there are modifications Deprecated: use . &Set the return code in your response. Same as  status >> return val.  Respond with 200 OK.  Respond with 500 Interal Server Error. Responds with 502 Bad Gateway.  Respond with 400 Bad Request.   Respond with 401 Unauthorized. ! Respond with  403 Forbidden. " Respond with  404 Not Found. # Respond with  303 See Other. $ Respond with  302 Found. % Respond with 301 Moved Permanently. & Respond with 307 Temporary Redirect. 'Deprecated: use . (!What is this for, exactly? I don't understand why Show a is even in the context X Deprecated: This function appears to do nothing at all. If it use it, let us know why. )A constructor for a  when you don't care about the request. *Again, why is this useful? W Deprecated: No idea why this function would be useful. If you use it, please tell us. +*A simple HTTP basic authentication guard. the realm name the username password map the part to guard ,Useful inside the ( monad. Gets the named input parameter  (either from a POST or a GET request). -#Get the named input parameter as a H. .Get the named input as a . /Get the named cookie. & The cookie name is case insensitive. 0Get the named cookie as a . 1&Get the named cookie as the requested i type. 2Like ., but i s for you. 33Get all the input parameters and convert them to a . 4This  modifier enables the use of  and  inside the   actions, by adding the ! monad transformer to the stack. -You can wrap the complete second argument to  in this function. 5)An example error Handler to be used with spUnWrapErrorT, which returns the 9 error message as a plain text message to the browser. KAnother possibility is to store the error message, e.g. as a FlashMsg, and % then redirect the user somewhere. 6This is a for use with 'mapServerPartT\'' It it unwraps the  interior monad for use with . If you have a  ServerPartT (ErrorT e m) a&, this will convert that monad into a  ServerPartT m a . Used with 'mapServerPartT\'' to allow   and  inside your monad. Eg.  a simpleHTTP conf $ mapServerPartT' (spUnWrapErrorT failurePart) $ myPart `catchError` errorPart  Note that  failurePart will only be run if  errorPart threw an error  so it doesn't have to be very complex. 7;Set the validator which should be used for this particular hc  when validation is enabled. CCalling this function does not enable validation. That can only be ( done by enabling the validation in the  that is passed to  . >You do not need to call this function if the validator set in   does what you want already. Example: (use <$ instead of the default supplied by 9)  U simpleHTTP validateConf . anyRequest $ ok . setValidator noopValidator =<< htmlPage  See also: 9, ;, <, = 8ServerPart version of 7. Example: (Set validator to <) K simpleHTTP validateConf $ setValidatorSP noopValidator (dir "ajax" ... ) 9Extend $ by enabling validation and setting  ; as the default validator for text/html.  Example: 4 simpleHTTP validateConf . anyRequest $ ok htmlPage :%Actually perform the validation on a hc. #Run the validator specified in the hc. If none is provide # use the supplied default instead. =Note: This function will run validation unconditionally. You  probably want 7 or 9. ; Validate text/html content with WDG HTML Validator. 1This function expects the executable to be named validate  and it must be in the default PATH.  See also: 7, 9, =. <#A validator which always succeeds. AUseful for selectively disabling validation. For example, if you @ are sending down HTML fragments to an AJAX application and the 8 default validator only understands complete documents. = Validate the hc using an external application. @If the external application returns 0, the original response is F returned unmodified. If the external application returns non-zero, a hc = containing the error messages and original response body is  returned instead. DThis function also takes a predicate filter which is applied to the B content-type of the response. The filter will only be applied if  the predicate returns true. ENOTE: This function requirse the use of -threaded to avoid blocking. 7 However, you probably need that for Happstack anyway.  See also: ;. name of executable %arguements to pass to the executable #optional path to working directory )optional environment (otherwise inherit) content-type filter Response to validate EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=})' !"#$%&     +(*,-./0123456789:;<=}      !"#$%&'()*+,-./0123456789:;<= >?@'Ready collection of common mime types. I Except for the first two entries, the mappings come from an Ubuntu 8.04 etcmime.types file. ABCDEreturn a simple File not found 404 page.  Similar to 3 but does not include the extension separator char FPrevents files of the form '.foo' or  'bar/.foo' from being served GJReturns True if the given String either starts with a . or is of the form  foo/.bar5, e.g. the typical *nix convention for hidden files. H.Use sendFile to send the contents of a Handle content-type string file path for content to send 6mod-time for the handle (MUST NOT be later than server'^s time of message origination), incoming request (used to check for if-modified-since header) offset into Handle number of bytes to send I'Send the contents of a Lazy ByteString content-type string (e.g. "text/plain; charset=utf-8")  lazy bytestring content to send [mod-time for the bytestring, incoming request (used to check for if-modified-since header) offset into the bytestring dnumber of bytes to send (offset + count must be less than or equal to the length of the bytestring) J'Send the contents of a Lazy ByteString content-type string (e.g. "text/plain; charset=utf-8")  lazy bytestring content to send [mod-time for the bytestring, incoming request (used to check for if-modified-since header) offset into the bytestring dnumber of bytes to send (offset + count must be less than or equal to the length of the bytestring) KFSend the specified file with the specified mime-type using sendFile() =NOTE: assumes file exists and is readable by the server. See N. +WARNING: No security checks are performed. content-type string path to file on disk LLSend the specified file with the specified mime-type using Lazy ByteStrings =NOTE: assumes file exists and is readable by the server. See N. +WARNING: No security checks are performed. content-type string path to file on disk MLSend the specified file with the specified mime-type using Lazy ByteStrings =NOTE: assumes file exists and is readable by the server. See N. +WARNING: No security checks are performed. content-type string path to file on disk N Serve a single, specified file.  example 1: 6Serve using sendfile() and the specified content-type  T serveFileUsing filePathSendFile (asContentType "image/jpeg") "/srv/data/image.jpg"  example 2: PServe using a lazy ByteString and the guess the content-type from the extension  Q serveFileUsing filePathLazy (guessContentTypeM mimeTypes) "/srv/data/image.jpg" +WARNING: No security checks are performed.  typically K, L, or M 9function for determining content-type of file. Typically C or B path to the file to serve O Alias for N K PNServe files from a directory and its subdirectories (parameterizable version) 5Parameterize this function to create functions like, Q, R, and S  You supply:  5 a low-level function which takes a content-type and  and generates a Response ; 2. a function which determines the content-type from the  + 3. a list of all the default index files ANOTE: unlike fileServe, there are no index files by default. See D. Ufunction which takes a content-type and filepath and generates a response (typically K, L, or M) 2function which returns the mime-type for FilePath <index file names, in case the requested path is a directory file/directory to serve QzServe files from a directory and its subdirectories (sendFile version). Should perform much better than its predecessors. <index file names, in case the requested path is a directory file/directory to serve ROServe files from a directory and its subdirectories (lazy ByteString version). May leak file handles. <index file names, in case the requested path is a directory file/directory to serve SRServe files from a directory and its subdirectories (strict ByteString version). ;index file names, in case the next argument is a directory file/directory to serve TUVW>?@ABCDEFGHIJKLMNOPQRSTUVW>@CABHIJKLMONPQRSFDTWUV?EG>?@ABCDEFGHIJKLMNOPQRSTUVW X Is equal to  haskell/Main Y Is equal to  public/log ZConvenience function around ? ) with the default binary location set to X and the  log location set to Y. XYZXYZXYZ [ reads the "Accept-Encoding" header. Then, if possible . will compress the response body with methods gzip or deflate &Returns the name of the coding chosen \/compresses the body of the response with gzip.  does not set any headers. ]-compresses the body of the response with zlib's  deflate method  does not set any headers. 1based on the rules describe in rfc2616 sec. 14.3 ^6unsupported: a parser for the Accept-Encoding header [\]^[\]^[\]^EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ !"##$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNNOPQRSTUVWXYZ[\\]^_`abcdefghijklmmnopqrstuvwxyz{|x}~                     X                  P                 ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 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 [ \ ] ^ _ ` a b c d e f g h ijkklmnopqrstuvwxyz{|}~xxmmnuv      !"#$%&'()*+,-./0123456789:;<=>>??@rABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop qrst4uvwbxayz{|}~  II              happstack-server-0.5.0.4Happstack.Server.HTTP.TypesHappstack.Server.MinHaXMLHappstack.Server.SURIHappstack.Server.CookieHappstack.Server.MessageWrapHappstack.Server.HTTP.LowLevelHappstack.Server.HTTP.ClientHappstack.Server.XSLTHappstack.Server.SimpleHTTPHappstack.Server.HTTP.FileServeHappstack.Server.StdConfigHappstack.Server.PartsHappstack.Server.HTTP.SocketTHHappstack.Server.HTTP.SocketHappstack.Server.HTTP.LazyLinerHappstack.Server.SURI.ParseURI#Happstack.Server.HTTP.RFC822HeadersHappstack.Server.HTTP.Clock"Happstack.Server.HTTPClient.StreamHappstack.Server.HTTPClient.TCP Happstack.Server.HTTPClient.HTTPPaths_happstack_serverHappstack.Server.HTTP.MultipartHappstack.Server.HTTP.HandlerHappstack.Server.HTTP.ListenHappstack.Server ContentTypectType ctSubtype ctParametersElStringelString ToElement toElementXMLElement StyleSheetXSLCSSstyleURLNoStyleStyleURL hasStyleURLisCSSisXSLtlexmlElemtextElem emptyElemlistElem cdataElem simpleDocOld simpleDoc simpleDoc' xmlEscaper xmlStdEscapeverbim simpleProlognonEmptygetRootwrapElemelFattrFattrFSattrFMbquoteEscrecToEllistToEltoAttrsFromPathfromPathToSURItoSURISURIsuripathqueryschemeu_schemeu_patha_schemea_pathunEscapeescapeisAbsrenderparseCookie cookieVersion cookiePath cookieDomain cookieName cookieValuesecuremkCookiemkCookieHeader parseCookies cookiesParser getCookies getCookie getCookies' getCookie'RqBodyBodyRequestrqMethodrqPathsrqUrirqQueryrqInputs rqCookies rqVersion rqHeadersrqBodyrqPeerResponseSendFile sfFilePathsfOffsetsfCountrsCode rsHeadersrsFlagsrsBody rsValidatorHostInput inputValue inputFilenameinputContentTypeRsFlagsrsfContentLengthHeaders HeaderPairhNamehValueMethodCONNECTOPTIONSTRACEDELETEPUTPOSTHEADGETConfport validatorVersion continueHTTPnullConf nullRsFlagsnoContentLengthrqURL setRsCode mkHeaders getHeader getHeaderBSgetHeaderUnsafe hasHeader hasHeaderBShasHeaderUnsafe setHeader setHeaderBSsetHeaderUnsafe addHeader addHeaderBSaddHeaderUnsaferesultresultBSredirect ReadString readString queryInput bodyInput formDecode decodeBodymultipartDecodebodyPartToInput simpleInputdefaultInputTypepathElsrequest parseResponse putRequestlistenOnlistenlisten' getResponse unproxify unrproxifyXSLPath XSLTCommandXSLTCmdxsltElem procLBSIO procFPSIOxsltFPS xsltFPSIO xsltStringxsltFilexsltprocsaxon ToMessage toContentType toMessage toResponseFromDatafromDataRqData FromReqURI fromReqURIWebMonad finishWithUnWebTWebTunWebT FilterMonad setFilter composeFilter getFilterFilterT unFilterT FilterFun SetAppendAppendSet ServerMonadaskRqlocalRq ServerPartT unServerPartT ServerPartWebrunServerPartT withRequestmapServerPartTmapServerPartT'noHandlerunWebTununWebTmkWebTmapWebT ignoreFiltersescape' parseConfig simpleHTTP simpleHTTP' simpleHTTP''simpleHTTPWithSocketsimpleHTTPWithSocket'bindPort toResponseBSflatten localContext getHeaderM addHeaderM setHeaderMguardRqmethodM methodOnlymethodSPmethodnullDirdirdirshostwithHosturiRestanyPathanyPath' trailingSlash getDataFngetDatawithData withDataFn proxyServe rproxyServerequirerequireMxsltdoXslt addCookie addCookies expireCookieifModifiedSincemodifyResponsesetResponseCoderespokinternalServerError badGateway badRequest unauthorized forbiddennotFoundseeOtherfoundmovedPermanently tempRedirectmulti debugFilter anyRequest applyRequest basicAuth lookInputlookBSlook lookCookielookCookieValuereadCookieValuelookRead lookPairserrorHandlerSPsimpleErrorHandlerspUnwrapErrorT setValidatorsetValidatorSP validateConf runValidatorwdgHTMLValidator noopValidatorlazyProcValidatorMimeMap errorwrapper mimeTypesguessContentTypeguessContentTypeM asContentTypedefaultIxFiles fileNotFound blockDotFilesisDotsendFileResponselazyByteStringResponsestrictByteStringResponsefilePathSendFile filePathLazyfilePathStrictserveFileUsing serveFile fileServe' fileServe fileServeLazyfileServeStrictdoIndex doIndexLazy doIndexStrictdoIndex'binarylocation loglocationerrWrapcompressedResponseFilter gzipFilter deflateFilter encodings supportsIPv6 acceptLiteLazynewLinerHandle headerLinesgetBytesStrictgetBytesgetResttoStrictbytestring-0.9.1.10Data.ByteString.LazytoChunks parseURIRefpabsuri pauthority pauthinner pauthportpurirefpquery pfragment unsafeTail unsafeHead unsafeIndexContentDispositionContentTransferEncodingbaseGHC.ShowShowshowContentTypeHeaderpHeaders parseHeaderspHeaderextraFieldLineshowParameters p_parameter pContentTypeparseContentTypeGHC.BasefailgetContentTypepContentTransferEncodingparseContentTransferEncodinggetContentTransferEncodingpContentDispositionparseContentDispositiongetContentDispositionparseMlookupMws1lexemecrLf lineString literalStringbuggyLiteralStringheaderNameChar especials tokencharp_token text_charsp_text quoted_pairmkTimeclockupdatergetApproximateTimeDebug debugStreamDbgStreamreadLine readBlock writeBlockcloseResult ConnError ErrorMisc ErrorParse ErrorClosed ErrorResetbindEhandleSocketErrormyrecvConn ConnClosedMkConnconnSockconnAddrconnBffrconnHost ConnectionConnRefgetRefopenTCP openTCPPort isConnectedTo Behaviour DieHorribly ExpectEntityDoneRetryContinuerspCode rspReason rspHeadersrspBody RequestData ResponseData ResponseCoderqURIGHC.Num* RequestMethod HasHeaders getHeaders setHeaders HeaderName HdrCustomHdrContentTransferEncodingHdrLastModified HdrExpiresHdrETagHdrContentTypeHdrContentRange HdrContentMD5HdrContentLocationHdrContentLengthHdrContentLanguageHdrContentEncodingHdrContentBaseHdrAllowHdrWWWAuthenticate HdrWarningHdrVary HdrSetCookie HdrServer HdrRetryAfter HdrPublicHdrProxyAuthenticate HdrLocationHdrAge HdrUserAgent HdrRefererHdrRangeHdrProxyAuthorizationHdrMaxForwardsHdrIfUnmodifiedSince HdrIfRangeHdrIfNoneMatch HdrIfMatchHdrIfModifiedSinceHdrHostHdrFrom HdrExpect HdrCookieHdrAuthorizationHdrAcceptLanguageHdrAcceptEncodingHdrAcceptCharset HdrAcceptHdrVia HdrUpgradeHdrTransferEncoding HdrPragmaHdrDate HdrConnectionHdrCacheControldebug httpLogFiletrimsplitcrlfsp headerMap insertHeaderinsertHeaderIfMissing replaceHeader insertHeadersretrieveHeaders findHeader lookupHeader httpVersion rqMethodMap parseHeaderparseRequestHeadparseResponseHead matchResponse simpleHTTP_getAuthsendHTTPsendHTTPPipelined receiveHTTP respondHTTPlinearTransferhopefulTransferchunkedTransferchunkedTransferCuglyDeathTransferreadTillEmpty1readTillEmpty2 urlDecode urlEncode urlEncodeVarsversionbindirlibdirdatadir libexecdir getBinDir getLibDir getDataDir getLibexecDirgetDataFileNameBodyPart MultiPartparseMultipartBodyData.ByteString.Lazy.Internal ByteStringhGetMultipartBodyGHC.IO.Handle.TypesHandle parseBodyPart splitParts dropPreamble Data.MaybeNothingsplitAtBoundary isBoundaryisClosestartsWithDashesdropLinesplitAtEmptyLine splitAtCRLF splitAtCRLF_findCRLF findCRorLFstartsWithCRLFdropCRLFfctllow updateHeadersheaders isHTTP1_1 isHTTP1_0getHeaderUnsafe' checkHeaderBScheckHeaderUnsafe locationCcloseC connectionC keepaliveCGHC.ReadRead hGetContentsN hGetContents'requiredtransferEncodingCrloop consumeChunksconsumeChunksImplcrlfLC lazylines requestLine responseLine staticHeadersputAugmentedResultaugmentHeaderspversionhttp09http10http11connectionCLower keepAliveCcrlfCfsepC contentTypeCcontentLengthCcontentlengthCdateC dateCLowerserverChappsC textHtmlCresponseMessagelog'logMXSaxonXSLTProc constr[a116Z] constr[a1170]dataType[a116Y]xsltCmdString xsltproc'saxon' xsltFileEx withTempFilereadFileStricttempDirtryAny MatchMethod matchMethodhappstack-util-0.5.0.3Happstack.Util.CommonreadMMonadMaybe Control.MonadmzeroJust Data.EitherEither Data.MonoidEndoDualMonoidtransformers-0.2.2.0Control.Monad.Trans.ReaderReaderTControl.Monad.Trans.ErrorErrorT mtl-2.0.1.0Control.Monad.Error.Class throwError catchErrorextract unFilterFunmemptyhoSystem.Console.GetOptOptDescrmsumGHC.IOFilePath proxyServe' mkFailMessagefailHtml escapeString notFoundHtmlioErrorsgetExtfilepath-1.2.0.0System.FilePath.Posix takeExtension bestEncodingallEncodingHandlers allEncodingshandlers