rj      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiportable experimental!dominic.steinitz@blueyonder.co.uk jklmnoBCut up a string into 72 char lines, each line terminated by CRLF. pqrstjostjostnon-portable (not tested) experimentalbjorn@bringert.net u?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 ;) vwxyz{>This is the type returned by many exported network functions. |}~ uvwxyz{|}~ uvwxyzvwxyz{|~}}~non-portable (not tested) experimentalbjorn@bringert.netEDThis class allows us to write generic header manipulation functions  for both Request and Response 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. @@2non-portable (not tested) experimentalbjorn@bringert.net!Allows stream logging. Refer to  below. Wraps a stream with logging I/O. 7 The first argument is a filename which is opened in  AppendMode. non-portable (not tested) experimentalbjorn@bringert.net)Exception handler for socket operations. non-portable (not tested) experimentalbjorn@bringert.net 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. 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.netGAn HTTP Response.  The : 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 : 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.      #Parse the authority part of a URL.  RFC 1732, section 3.1:  4 //<user>:<password>@<host>:<port>/<url-path> @ Some or all of the parts "<user>:<password>@", ":<password>", 0 ":<port>", and "/<url-path>" may be excluded. 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.  !"#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. ,-"Converts a single value from the  application/ x-www-form-urlencoded encoding. >Replaces all instances of a value in a list by another value. Value to look for Value to replace it with  Input list  Output list ./vuvwxyz{|}~     !#$,./(         !#$,./0123456789_search the cookie with the given name in the headers (request headers) and get the session id. - Then search the Session Map for the value  set the value in a new session. / Then set responses headers with the cookie.          !"#$%&'()*+,-./012345678' !"#$%&'()*+:;<,-./012=34>5?@678   !"# !"#$%&'()*+,-./01234567809:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh09:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh09:;:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh iABCDEFGHIiil  !"#$%&'()*+:;<,-./012=34>5?@6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghie !"#$&%'()*+,-./012345678=><9:;?@ABCDEFGHIJKLMNOPQRTSUVWXYZ[\]^_`abcdefgh  iJ             ! " # $ % & ' ( ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E FGGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                     i       ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 89:;<=>?@AB C D E F G H IJKLMNOPQRSredHandlers-0.1Network.HTTP.RedHandler.SessionNetwork.HTTP.RedHandler-Network.HTTP.RedHandler.HTTP_Fork.HTTP.Base64(Network.HTTP.RedHandler.HTTP_Fork.Stream.Network.HTTP.RedHandler.HTTP_Fork.HTTP.Headers0Network.HTTP.RedHandler.HTTP_Fork.StreamDebugger.Network.HTTP.RedHandler.HTTP_Fork.StreamSocket%Network.HTTP.RedHandler.HTTP_Fork.TCP!Network.HTTP.RedHandler.FileUtilsNetwork.HTTP.RedHandler.Utils&Network.HTTP.RedHandler.HTTP_Fork.HTTP Network.HTTP.RedHandler.Response&Network.HTTP.RedHandler.RequestContextNetwork.HTTP.RedHandler.HandlerNetwork.HTTP.RedHandler.Httpd SessionStategetSessionedStateWithCookienewSessionedStateWithCookieupdateSessionedStateWithCookiedeleteSessionedStateWithCookie BasicRspBodyStrRespFileRespBasicRspNon200Response RedirectResp HandlerRsp hanRspHeaders hanRspBodynon200responseokHTTPStrResponseredirectResponse redirectToRsp basicRspWithfileRspmaybeBasicRspToResponsenotFoundResponsebasicRspToResponsebasicRspBodyToResponseRequestContextoriginalRequest requestTimedirsdocNameformat customQuery formInputs consumedDirsrestrictByParentQueryquerymoveForwardDirmoveBackwardDir completeDirs completeURLpendingURIPath renderQuerymkRqCtx orIfEmpty hasCookie postFieldspostFieldFileName postFieldrun showParsesaddResourceIdToCollAddraddMethodToCollAddraddMethodToResAddraddHierarchicalCollToResAddrsetCollectionFromRootAddrupgradeQueriesForHierarchy RqHandlerT unRqHandlerT IORqHandler mapMaybeTmaybeToMonadPlus runRqHandlerT mapRqHandlerTnotMeanyOfifReq underStringunder underIntegerreprocessLastDir underNoDir withDocNamewithDocNameIntegerwithDocNameStringmodReqmodResp filterReqsatifMethodformatEq formatHtmlifGetifPosteqfailWith getResponserespWithStaticmapDir printString printFullReqdebugdebugStrprintReq withRequestDo withParam maybeReadswithQueryField withQuery withPostFieldwithPostFieldswithPostFieldFileName showReqHtmlshowReq runHttpServerOctet encodeArray int4_char3 char3_int4enc1chop72 quadrupletsencdcdencodedecodeStreamreadLine readBlock writeBlockwriteBlockWithFilecloseResult ConnError ErrorMisc ErrorParse ErrorClosed ErrorResetbindE HasHeaders getHeaders setHeaders HeaderName HdrCustomHdrContentTransferEncodingHdrLastModified HdrExpiresHdrETagHdrContentTypeHdrContentRange HdrContentMD5HdrContentLocationHdrContentLengthHdrContentLanguageHdrContentEncodingHdrContentBaseHdrAllowHdrWWWAuthenticate HdrWarningHdrVary HdrSetCookie HdrServer HdrRetryAfter HdrPublicHdrProxyAuthenticate HdrLocationHdrAge HdrUserAgent HdrRefererHdrRangeHdrProxyAuthorizationHdrMaxForwardsHdrIfUnmodifiedSince HdrIfRangeHdrIfNoneMatch HdrIfMatchHdrIfModifiedSinceHdrHostHdrFrom HdrExpect HdrCookieHdrAuthorizationHdrAcceptLanguageHdrAcceptEncodingHdrAcceptCharset HdrAcceptHdrVia HdrUpgradeHdrTransferEncoding HdrPragmaHdrDate HdrConnectionHdrCacheControlHeadertrimsplitcrlf headerMap insertHeaderinsertHeaderIfMissing replaceHeader insertHeadersretrieveHeaders findHeader lookupHeader parseHeader parseHeadersStreamDebugger debugStreamDbghandleSocketErrormyrecvConn ConnClosedMkConnconnSockconnAddrconnBffrconnHost ConnectionConnRefgetRef openTCPPort isConnectedTosendFileResponsestatFilefindRealFilename lookupByFunsafeHeadmapFstmapSndlowfst3snd3trd3fst4snd4trd4fourth4 Behaviour DieHorribly ExpectEntityDoneRetryContinueResponsebaseGHC.ShowShowrspCode rspReason rspHeadersrspBody ResponseBodyStringRespBodyFileBody RequestData ResponseData ResponseCodeRequestrqURIGHC.Num*rqMethod rqHeadersrqBody RequestMethodTRACEOPTIONSDELETEPOSTGETPUTHEAD URIAuthorityuserpasswordhostport httpLogFilespparseURIAuthority pURIAuthority pUserInfobefore orNothing httpVersion rqMethodMapparseRequestHeadparseResponseHead matchResponse simpleHTTP simpleHTTP_getAuthsendHTTPuriToAuthorityString receiveHTTP respondHTTPlinearTransferhopefulTransferchunkedTransferchunkedTransferCuglyDeathTransferreadTillEmpty1readTillEmpty2 urlDecodereplace urlEncode urlEncodeVars SessionMap sessionMap addSession updateSession readSession deleteSessionexportSessionMaplookupCookieValue setCookie removeCookieparseURLparseDir parseQuerytupaddMethodNewToCollAddraddMethodEditToResAddraddMethodDeleteToResAddrhandleConnectiongetRequestContextmkRqCtx'runRequestHandler responseSendacceptConnectionsendFilesquirtsniff