~[Y      !"#$%&'()*+,-./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  YYYZEalternative implementation of accept to work around EAI_AGAIN errors ZZ [\]^_`abcde[[portable experimental lemmih@vo.com)fghiA MIME media type value.  The j$ instance is derived automatically.  Use k 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"). lmnopqrk>Produce the standard string representation of a content-type,  e.g. "text/html; charset=ISO-8859-1". st5Parse the standard representation of a content-type. 6 If the input cannot be parsed, this function calls  u/ with a (hopefully) informative error message. vwxyz{|}~RFC 822 LWSP-char #RFC 822 CRLF (but more permissive)  One line fghilmnoktvxy{|}fgghiilmnoktvxy{|}non-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 j: 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 j: 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. *'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. +A necessary feature of HTTP/1.1 , Also the only transfer variety likely to  return any footers. ,-2Maybe in the future we will have a sensible thing 4 to do here, at that time we might want to change  the name. .DRemove leading crlfs then call readTillEmpty2 (not required by RFC) /'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. 012w    "#%&'(012Z2       "#%&'(012-  !"#$%&'()*+,-./01-  !"#$%&'()*+,-./01.   !"#$%&'(  )*+,-./01-   !"#$%&'()*+,-./01 3456789:;<389:;<389:;<xbnon-portable experimental lemmih@vo.com=>?@A!Read a multi-part message from a B.  Boundary C!Read a multi-part message from a D.  Fails on parse errors.  Boundary EF4Split a multipart message into the multipart parts. )The boundary, without the initial dashes G=Drop everything up to and including the first line starting  with the boundary. Returns H if there is no " line starting with a boundary. )The boundary, without the initial dashes I+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 H if there is no boundary. J:Check whether a string starts with two dashes followed by  the given boundary string. )The boundary, without the initial dashes K!Check whether a string for which J returns true , has two dashes after the boudary string. )The boundary, without the initial dashes L0Checks whether a string starts with two dashes. M4Drop everything up to and including the first CRLF. NESplit 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.  H( is returned if there is no empty line. O;Split a string at the first CRLF. The CRLF is not included # in any of the returned strings. String to split. Returns H if there is no CRLF. PLike O%, but if no CRLF is found, the first B result is the argument string, and the second result is empty. Q4Get the index and length of the first CRLF, if any. String to split. RST7Drop 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. fghiltvxy{|=>?@ACNO=>>?@@ACNO2344Convenience 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 ' '. UO9Not 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. STVEFGHIJKLMNOPQRSTEFGHIJKLMNQRSTOPEFGHIJKLFGHIJKLMNOPQRSTXUVWXYWXYZ[\]^_`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 Z[?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. \DLookup 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. ]^Associates 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 _`abQUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~UWXYZ[\]^_`abchdijklmijkmefgUVopqrsxyz{tuv|~}wnLUVVW XYZ[\]^_`abXYZ[\]^_`abchdijklmijkmefgdefghijklmnopqrspqrstuvuvwxyz{yz{|~}}~ Like c& 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. $def=Unserializes the bytestring into a response. If there is an  error it will return Left msg. ghijklmnop+Serializes the request to the given handle qrstuvwxyz{|}~Bind and listen port &Use a previously bind port and listen VUVWXYZ[\]^_`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.comMinimal definition:  NUsed to convert arbitrary types into an HTTP response. You need to implement  this if you want to pass  ServerPartT m& containing your type into simpleHTTP Useful for withData 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 3 path component which looks like this as a String: / somestring/ 6instead of requiring the path component to look like: / somestring/ A control structure E It ends the computation and returns the Response 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 F force you to convert all your return types to Response early just to  accomodate this. AIt is worth discussing the unpacked structure of WebT a bit as it' s exposed  in  and . 7A fully unpacked WebT has a structure that looks like:  M ununWebT $ WebT m a :: m (Maybe (Either Response a, FilterFun Response)) KSo, ignoring m, as it is just the containing Monad, the outermost layer is  a Maybe. This is H if  was called or Just (Either Response  a, SetAppend (Endo Response)) if  wasn't called. Inside the Maybe, J there is a pair. The second element of the pair is our filter function  FilterFun Response. FilterFun Response is a type alias for  SetAppend  (Dual (Endo Response)) . This is just a wrapper for a Response->Response 9 function with a particular Monoid 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. ZAnother way of looking at all these pieces is from the behaviors they control. The Maybe  controls the mzero behavior.  Set (Endo f)$ comes from the setFilter behavior.  Likewise, Append (Endo f) is from composeFilter.  Left Response is what you  get when you call  finishWith and Right a is the normal exit. &An example case statement looks like:    ex1 webt = do  val <- ununWebT webt  case val of P Nothing -> Nothing -- this is the interior value when mzero was used V Just (Left r, f) -> Just (Left r, f) -- r is the value that was passed into  finishWith K -- f is our filter function R Just (Right a, f) -> Just (Right a, f) -- a is our normal monadic value S -- f is still our filter function   $The basic response building object. GA set of functions for manipulating filters. A ServerPartT implements C FilterMonad Response so these methods are the fundamental ways of 8 manipulating the response object, especially before you've converted your  monadic value to a hc Ignores all previous  alterations to your filter As an example:   do  composeFilter f  setFilter g  return " Hello World" 5setFilter g will cause the first composeFilter to be  ignored. 'composes 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. L If a is a monoid, then SetAppend is a monoid with the following behaviors:   Set x  Append y = Set (x  y)  Append x  Append y = Append (x  y)  _  Set y = Set y JA simple way of sumerizing this is, if the right side is Append, then the N 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. 5 Why you ask? Because ServerT can lift up a ReaderT. ) If you did that, it would shadow ServerT' s behavior 6 as a ReaderT, thus meaning if you lifted the ReaderT 3 you could no longer modify the Request. This way 3 you can add a ReaderT to your monad stack without  any trouble. IServerPartT is a container for processing requests and returning results 1An 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 7 monad into a ServerPartT, since simpleHTTP requires a ServerPartT IO a.  Refer to 3 for an explanation of the structure of the monad. CHere is an example. Suppose you want to embed an ErrorT into your @ ServerPartT to enable throwError and catchError in your Monad.  9 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. simpleHTTP). You  can provide the function:  K unpackErrorT:: (Monad m, Show e) => UnWebT (ErrorT e m) a -> UnWebT m a  unpackErrorT handler et = do  eitherV <- runErrorT et  case eitherV of * Left err -> return $ Just (Left Catastrophic failure  ++ show e, Set $ Endo r -> r{rsCode = 500})  Right x -> return x With  unpackErrorT. you can now call simpleHTTP. Just wrap your  ServerPartT list.  = simpleHTTP nullConf $ mapServerPartT unpackErrorT (myPart ` catchError` myHandler) Or alternatively:   simpleHTTP' unpackErrorT nullConf (myPart ` catchError` myHandler)  Also see 13 for a more sophisticated version of this function LA varient of mapServerPartT where the first argument, also takes a request. M useful if you want to runServerPartT on a different ServerPartT inside your  monad (see spUnwrapErrorT) #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 mzero takes your WebT, if it is  it returns Nothing else it A converts the value to a Response and applies your filter to it. <for when you really need to unpack a WebT entirely (and not * just unwrap the first layer with unWebT) for wrapping a WebT back up. mkWebT . ununWebT = id see # for a discussion of this function An alias for setFilter id  It resets all your filters  Used to ignore all your filters 8 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  5parseConfig tries to parse your command line options  into a Conf. =Use the built-in web-server to serve requests according to a . F Use msum to pick the first handler from a list of handlers that doesn't call  noHandle. a combination of simpleHTTP'' and . See  for a discussion ) of the first argument of this function. Generate a result from a  and a XW. This is mainly used ! by CGI (and fast-cgi) wrappers. IRun simpleHTTP 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 7 tid <- forkIO $ socketSimpleHTTP socket conf impl Note: It'As important to use the same conf (or at least the same port) for   and .  with a socket $Bind port and return the socket for  flatten turns your arbitrary m a and converts it too  a m hc with  AThis is kinda like a very oddly shaped mapServerPartT or mapWebT . You probably want one or the other of those.  Get a header out of the request  adds headers into the response. 9 This method does not overwrite any existing header of 5 the same name, hence the name addHeaderM. If you , want to replace a header use setHeaderM. 4sets a header into the response. This will replace > an existing header of the same name. Use addHeaderM, if you 4 want to add more than one header of the same name. 1guard using an arbitrary function on the request =Guard against the method. This function also guards against > any remaining path segments. See methodOnly 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 id deprecated. You can probably % just use methodSP (or methodM) now. 0Guard against non-empty remaining path segments Pop a path element and run the  ServerPartT! if it matches the given string. Guard against the host 2Lookup the host header and pass it to the handler *Pop a path element and parse it using the  in the  class. Ggrabs the rest of the URL (dirs + query) and passes it to your handler Kpops any path element and ignores when chosing a ServerPartT to handle the  request. Deprecated. Use . 0guard which checks that the Request URI ends in \/. # Useful for distinguishing between foo and foo/ Eused to read parse your request with a RqData (a ReaderT, basically) H For example here is a simple GET or POST variable based authentication K 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  7An varient of getData that uses FromData to chose your # RqData 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.  =withDataFn is like with data, but you pass in a RqData monad  for reading.  &proxyServe is for creating ServerPartT'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 Request and creates a Response. Your basic proxy  building block. See  *TODO: this would be more useful if it didn't call escape (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 escape , 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 varient 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. deprecated. Same as  &sets the return code in your response /adds the cookie with a timeout to the response 6adds the list of cookie timeout pairs to the response *honor if-modified-since header in Request  If the XW/ includes the if-modified-since header and the A Response 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 -same as setResponseCode 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. Just use msum #!what is this for, exactly? I don't understand why Show a is even in the context $ This appears to do nothing at all. $,a constructor for a ServerPartT when you don't care about the request %again, why is this useful? &)a simple HTTP basic authentication guard the realm name the username password map the part to guard 'HUseful inside the RqData monad. Gets the named input parameter (either  from a POST or a GET) (5Gets the named input parameter as a lazy byte string )!Gets the named input as a String *Gets the named cookie % the cookie name is case insensitive +"gets the named cookie as a string ,1gets the named cookie as the requested Read type -like look, but Reads for you. .=gets all the input parameters, and converts them to a string /QThis ServerPart modifier enables the use of throwError and catchError inside the F WebT actions, by adding the ErrorT monad transformer to the stack. -You can wrap the complete second argument to  in this function. 0)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. 1%This is a for use with mapServerPartT' It it unwraps 5 the interior monad for use with simpleHTTP. If you 6 have a ServerPartT (ErrorT e m) a, this will convert / that monad into a ServerPartT m a. Used with  mapServerPartT'0 to allow throwError and catchError inside your  monad. Eg.  # 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. 2;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 7$ instead of the default supplied by 4)  J simpleHTTP validateConf . anyRequest $ ok . setValidator noopValidator =<< htmlPage  See also: 4, 6, 7, 8 3ServerPart version of 2 Example: (Set validator to 7)  ? simpleHTTP validateConf $ setValidatorSP noopValidator (dir ajax ... )  See also: 2 4 This extends $ by enabling validation and setting  6 as the default validator for text/html.  Example:  5 simpleHTTP validateConf . anyRequest $ ok htmlPage 5%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 2 or 4. 6 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: 2, 4, 8 7#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. 8 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: 6 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{|}~      !"#$%&'()*+,-./012345678y$" !   &  #%'()*+,-./012345678y      !"#$%&'()*+,-./012345678 9:;'Ready collection of common mime types. I Except for the first two entries, the mappings come from an Ubuntu 8.04 etcmime.types file. <=>? Similar to 3 but does not include the extension separator char @Prevents files of the form '.foo' or  'bar/.foo' from being served AJReturns 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. B.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 C'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) D'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) EFSend the specified file with the specified mime-type using sendFile() =NOTE: assumes file exists and is readable by the server. See H. +WARNING: No security checks are performed. content-type string path to file on disk FLSend the specified file with the specified mime-type using Lazy ByteStrings =NOTE: assumes file exists and is readable by the server. See H. +WARNING: No security checks are performed. content-type string path to file on disk GLSend the specified file with the specified mime-type using Lazy ByteStrings =NOTE: assumes file exists and is readable by the server. See H. +WARNING: No security checks are performed. content-type string path to file on disk H 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 E, F, or G 9function for determining content-type of file. Typically > or = path to the file to serve I Alias for H E J#Serve files from a directory and it'+s subdirectories (parameterizable version) 5Parameterize this function to create functions like, K, L, and M  You supply: 71. 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 ?. Ufunction which takes a content-type and filepath and generates a response (typically E, F, or G) 2function which returns the mime-type for FilePath 'index files if the path is a directory file/directory to serve K#Serve files from a directory and it'Ws subdirectories (sendFile version). Should perform much better than its predecessors. 'index files if the path is a directory file/directory to serve L#Serve files from a directory and it',s subdirectories (lazy ByteString version). May leak file handles. 'index files if the path is a directory file/directory to serve M#Serve files from a directory and it'/s subdirectories (strict ByteString version). 'index files if the path is a directory file/directory to serve NOPQ9:;<=>?@ABCDEFGHIJKLMNOPQ9;><=BCDEFGIHJKLM@?NQOP:A9:;<=>?@ABCDEFGHIJKLMNOPQ R Is equal to  haskell/Main S Is equal to  public/log TConvenience function around : ) with the default binary location set to R and the  log location set to S. RSTRSTRST U 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 V/compresses the body of the response with gzip.  does not set any headers. W-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 X6unsupported: a parser for the Accept-Encoding header UVWXUVWXUVWXEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRST !"##$%&'()*+,-./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 cdefghijklmnoppqqrstuvwxyz{|}~rxxmmrnuv vv    x !"#$%&'()*+,-./012345678899:;<=r>?@ABrCDEFGHIJKLMNOPQRSTUVWXYZ[\]r^_`abcdefgh ijkl.mno\p[qrstuvwxyz{|}~r  rr  r r         r    happstack-server-0.4.1Happstack.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.SURI.ParseURI#Happstack.Server.HTTP.RFC822HeadersHappstack.Server.HTTP.LazyLinerHappstack.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 putRequestlistenlisten' 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'bindPortflatten localContext getHeaderM addHeaderM setHeaderMguardRqmethodM methodOnlymethodSPmethodnullDirdirhostwithHosturiRestanyPathanyPath' trailingSlash getDataFngetDatawithData withDataFn proxyServe rproxyServerequirerequireMxsltdoXsltmodifyResponsesetResponseCode addCookie addCookiesifModifiedSinceokinternalServerError badGateway badRequest unauthorized forbiddennotFoundseeOtherfoundmovedPermanently tempRedirectmulti debugFilter anyRequest applyRequest basicAuth lookInputlookBSlook lookCookielookCookieValuereadCookieValuelookRead lookPairserrorHandlerSPsimpleErrorHandlerspUnwrapErrorT setValidatorsetValidatorSP validateConf runValidatorwdgHTMLValidator noopValidatorlazyProcValidatorMimeMap errorwrapper mimeTypesguessContentTypeguessContentTypeM asContentTypedefaultIxFiles blockDotFilesisDotsendFileResponselazyByteStringResponsestrictByteStringResponsefilePathSendFile filePathLazyfilePathStrictserveFileUsing serveFile fileServe' fileServe fileServeLazyfileServeStrictdoIndex doIndexLazy doIndexStrictdoIndex'binarylocation loglocationerrWrapcompressedResponseFilter gzipFilter deflateFilter encodings supportsIPv6 acceptLite parseURIRefpabsuri pauthority pauthinner pauthportpurirefpquery pfragment unsafeTail unsafeHead unsafeIndexContentDispositionContentTransferEncodingbaseGHC.ShowShowshowContentTypeHeaderpHeaders parseHeaderspHeaderextraFieldLineshowParameters p_parameter pContentTypeparseContentTypeGHC.BasefailgetContentTypepContentTransferEncodingparseContentTransferEncodinggetContentTransferEncodingpContentDispositionparseContentDispositiongetContentDispositionparseMlookupMws1lexemecrLf lineString literalStringbuggyLiteralStringheaderNameChar especials tokencharp_token text_charsp_text quoted_pairLazynewLinerHandle headerLinesgetBytesStrictgetBytesgetResttoStrictbytestring-0.9.1.6Data.ByteString.LazytoChunksmkTimeclockupdatergetApproximateTimeDebug 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.ReadReadrequiredtransferEncodingCrloop consumeChunksconsumeChunksImplcrlfLC lazylines requestLine responseLine staticHeadersputAugmentedResultaugmentHeaderspversionhttp09http10http11connectionCLower keepAliveCcrlfCfsepC contentTypeCcontentLengthCcontentlengthCdateC dateCLowerserverChappsC textHtmlCresponseMessagelog'logMXSaxonXSLTProc constr[aUQq] constr[aUQr]dataType[aUQp]xsltCmdString xsltproc'saxon' xsltFileEx withTempFilereadFileStricttempDirtryAny MatchMethod matchMethodhappstack-util-0.4.1Happstack.Util.CommonreadM Control.Monadmzero Data.Monoidmappend mtl-1.1.0.2Control.Monad.ReaderReaderTextract unFilterFunmemptyhoSystem.Console.GetOptOptDescr proxyServe'resp mkFailMessagefailHtml escapeString notFoundHtmlioErrors fileNotFoundgetExtfilepath-1.1.0.4System.FilePath.Posix takeExtensionGHC.IOFilePath bestEncodingallEncodingHandlers allEncodingshandlers