"       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~           $      !"#$%&'()*+,              portable experimental!dominic.steinitz@blueyonder.co.uk -./012BCut up a string into 72 char lines, each line terminated by CRLF. 34567-267-267 portable experimental!dominic.steinitz@blueyonder.co.uk89 Take [Octet] and return [Octet] according to the standard. H The length of the result is always 16 octets or 128 bits as required  by the standard. 8989non-portable (not tested) experimental)Sigbjorn Finne <sigbjorn.finne@gmail.com>:crlf* is our beloved two-char line terminator. ;split delim ls# splits a list into two parts, the delim occurring % at the head of the second list. If delim isn't in ls, Nothing is  returned. <trim str. removes leading and trailing whitespace from str. = trimL str+ removes leading whitespace (as defined by >)  from str. ? trimL str, removes trailing whitespace (as defined by >)  from str. @splitMany delim ls removes the delimiter delim from ls. :;<=?@:;<=?@non-portable (not tested) experimentalbjorn@bringert.net?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.        non-portable (not tested) experimentalbjorn@bringert.netBDThis 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. +Long discussions can be had on this topic! 1Allows for unrecognised or experimental headers. $MIME entity headers (for sub-parts)  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEThe Header data type pairs header names & values. FAGHIJ0Inserts 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. K)Gets a list of headers with a particular . L<Lookup presence of specific HeaderName in a list of Headers 3 Returns the value from the first matching header. MBN@ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN@EFDCBA@?>=<;:9876543210/.-,+*)('&%$#"! GHJKILMN@2DCBA@?>=<;:9876543210/.-,+*)('&%$#"!  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFFGHIJKLMNnon-portable (not tested) experimental)Sigbjorn Finne <sigbjorn.finne@gmail.com>OPQRSTUVWXYZ[\]^The  BufferType3 class encodes, in a mixed-mode way, the interface A that the library requires to operate over data embedded in HTTP ? requests and responses. That is, we use explicit dictionaries ; for the operations, but overload the name of these dicts. _`abOPQRSTUVWXYZ[\]^_`ab^_OPQRSTUVWXYZ[\]`abOPQRSTUVWXYZ[\]PQRSTUVWXYZ[\]^__`abnon-portable (not tested) experimental)Sigbjorn Finne <sigbjorn.finne@gmail.com>FcdefghiAn HTTP Response.  The C: 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. jklmno RequestData. contains the head of a HTTP request; method, ! its URL along with the auxillary/supporting header data. p ResponseData* contains the head of a response payload; < HTTP response code, accompanying text description + header  fields. q/For easy pattern matching, HTTP response codes xyz are  represented as (x,y,z). rAn HTTP Request.  The C: instance of this type is used for message serialisation, % which means no body data is output. stmight need changing in future  1) to support D uri in OPTIONS request + 2) transparent support for both relative  &% absolute uris, although this should  already work (leave scheme & host parts empty). uvwxyz{|+The HTTP request method, to be used in the sr 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. EFGHI getAuth req9 fishes out the authority portion of the URL in a request's Host  header. 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. J2Maybe 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.  catchIO a hD handles IO action exceptions throughout codebase; version-specific  tweaks better go here. @cdefghijklmnopqrstuvwxyz{|}~@rstuvwijklmn|~}{zyxchgfedpqo@chgfeddefghijklmnjklmnopqrstuvwstuvwxyz{|~}}~non-portable (not tested) experimentalbjorn@bringert.net+KLMNOPQRSTUThe - newtype is a wrapper that allows us to make F connections an instance of the Stream class, 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. VW3This function establishes a connection to a remote  host, it uses  getHostByName which interrogates the 5 DNS system, hence may trigger a network connection. XY4Checks both that the underlying Socket is connected 0 and that the connection peer matches the given ( host name (which is recorded locally). Z[\]^_`anon-portable (not tested) experimentalbjorn@bringert.net!Allows stream logging. Refer to  below. bWraps a stream with logging I/O. 7 The first argument is a filename which is opened in  AppendMode. cnon-portable (not tested) experimentalbjorn@bringert.net)Exception handler for socket operations. defnon-portable (not tested) experimental)Sigbjorn Finne <sigbjorn.finne@gmail.com> 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. ghiHReceive 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. jklnon-portable (not tested) experimentalbjorn@bringert.net !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNcdefghijklmnopqrstuvwxyz{|}~ non-portable (not tested) experimentalbjorn@bringert.net mnASimple 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. opqHReceive 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.   non-portable (not tested) experimental)Sigbjorn Finne <sigbjorn.finne@gmail.com>r3 is the enumerated list of events that the browser 8 internals will report to a user-defined event handler. ; is the event record type that a user-defined handler, set  via 5, will be passed. It indicates various state changes * in the processing of a given Request ID. stunumber of 401 responses so far vnumber of redirects so far wnumber of retrys so far x!whether to pre-empt 401 response yz{|}~5Specifies if a proxy should be used for the request. +Use the proxy given. Should be of the form http://host:port, host,  host:port, or  http://host Don't use a proxy. 0Returns a URI that is consistent with the first 4 argument uri when read in the context of a second. 2 If second argument is not sufficient context for , determining a full URI then anarchy reins. /Serialise a Cookie for inclusion in a request. 9Adds a cookie to the browser state, removing duplicates. 8Convert WWW-Authenticate header into a Challenge object 0Return authorities for a given domain and path.  Assumes dom is lower case  Interacting with browser state: 3Retrieve a likely looking authority for a Request. *Asking the user to respond to a challenge 5Generating a credentials value from an Authority, in 7 the context of a specific request. If a client nonce 1 was to be used then this function might need to ( be of type ... -> BrowserAction String #Apply a browser action to a state. Alter browser state Do an io action @C@ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUUVWXYZ[\]^^_`abcdefghijklmnopqrstuvwwxyz{|}~                                                          ! " # $ % & ' ( ) * + , - . / 0 & 123456789:;5<=5>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde f g ` b a h i i j k l m n o p q r s t u v w x y z { | } ~                       &                                 HTTP-4000.0.4Network.StreamNetwork.HTTP.HeadersNetwork.BufferTypeNetwork.HTTP.Base Network.TCPNetwork.StreamDebuggerNetwork.StreamSocketNetwork.HTTP.HandleStreamNetwork.HTTP.StreamNetwork.BrowserNetwork.HTTP.MD5AuxNetwork.HTTP.Base64Network.HTTP.MD5Network.HTTP.Utils Network.HTTPStreamreadLine readBlock writeBlockcloseResult ConnError ErrorMisc ErrorParse ErrorClosed ErrorReset failParsefailWithbindEfmapE HasHeaders getHeaders setHeaders HeaderName HdrCustomHdrContentTransferEncodingHdrLastModified HdrExpiresHdrETagHdrContentTypeHdrContentRange HdrContentMD5HdrContentLocationHdrContentLengthHdrContentLanguageHdrContentEncodingHdrContentBaseHdrAllowHdrWWWAuthenticate HdrWarningHdrVary HdrSetCookie HdrServer HdrRetryAfter HdrPublicHdrProxyAuthenticate HdrLocationHdrAge HdrUserAgent HdrRefererHdrRangeHdrProxyAuthorizationHdrMaxForwardsHdrIfUnmodifiedSince HdrIfRangeHdrIfNoneMatch HdrIfMatchHdrIfModifiedSinceHdrHostHdrFrom HdrExpect HdrCookieHdrAuthorizationHdrAcceptLanguageHdrAcceptEncodingHdrAcceptCharset HdrAcceptHdrVia HdrUpgradeHdrTransferEncoding HdrPragmaHdrDate HdrConnectionHdrCacheControlHeader insertHeaderinsertHeaderIfMissing replaceHeader insertHeadersretrieveHeaders findHeader lookupHeader parseHeadersBufferOpbuf_hGetbuf_hGetContentsbuf_hPut buf_hGetLine buf_empty buf_append buf_fromStr buf_toStrbuf_snoc buf_splitAtbuf_spanbuf_isLineTerm buf_isEmpty BufferType bufferOpsstrictBufferOp lazyBufferOpstringBufferOpResponseNextStep DieHorribly ExpectEntityDoneRetryContinueResponserspCode rspReason rspHeadersrspBody RequestData ResponseData ResponseCodeRequestrqURIrqMethod rqHeadersrqBody HTTPResponse HTTPRequestResponse_StringRequest_String RequestMethodTRACEOPTIONSDELETEPOSTGETPUTHEAD URIAuthorityuserpasswordhostportparseURIAuthorityuriToAuthorityStringuriAuthToString httpVersioncrlfspparseRequestHeadparseResponseHead matchResponse urlDecode urlEncode urlEncodeVarsgetAuthnormalizeRequestURInormalizeHostHeader findConnCloselinearTransferhopefulTransferchunkedTransferuglyDeathTransferreadTillEmpty1readTillEmpty2catchIOcatchIO_responseParseErrorHStream openStream StreamHooks hook_readLinehook_readBlockhook_writeBlock hook_close HandleStream Connection nullHookssetStreamHooks openTCPPortopenTCPConnection isConnectedToisTCPConnectedToStreamDebugger debugStreamdebugByteStreamhandleSocketErrormyrecv simpleHTTPsimpleHTTP_debug simpleHTTP_sendHTTPsendHTTP_notify receiveHTTP respondHTTPFormBrowserEventTypeResponseFinish ResponseEnd RequestSentReuseConnectionOpenConnection BrowserEventbrowserTimestampbrowserRequestIDbrowserRequestURIbrowserEventType RequestID BrowserAction BrowserStateProxyNoProxy Authority AuthDigestauNonce auAlgorithmauDomainauOpaqueauQop AuthBasicauRealm auUsername auPasswordauSiteCookie uriDefaultTo uriTrimHostdefaultCookieFilteruserCookieFilter addCookie setCookies getCookiessetCookieFiltergetAuthoritiessetAuthorities addAuthoritygetAuthorityGensetAuthorityGensetAllowBasicAuthbrowsegetBrowserStatewithBrowserStateioAction setErrHandler setOutHandlerouterrsetAllowRedirectsgetAllowRedirectssetProxy setDebugLogsetEventHandlerrequestdefaultGETRequestdefaultGETRequest_ formToRequestMD5get_nextlen_padfinishedWordListBoolListStrABCDRotationXYZZord64rotLmd5md5smd5imd5_main md5_do_block md5_roundmd5_inner_functionmd5_fmd5_gmd5_hmd5_i magic_numbersroundsabcd_to_stringdisplay_32bits_as_hexabcd_to_integerrev_numstring_to_word32sbools_to_word32slength_to_charsOctet encodeArray int4_char3 char3_int4enc1chop72 quadrupletsencdcdencodedecodehashsplittrimtrimLbase GHC.UnicodeisSpacetrimRsplitBy headerMap parseHeaderGHC.ShowShowGHC.Num* pURIAuthority pUserInfobefore orNothing rqMethodMapchunkedTransferCConn ConnClosedMkConnconnSock connHandle connBuffer connInputconnHost connHooksgetRef connHooks'openTCPConnection_closeConnection readBlockBS readLineBS writeBlockBScloseItbufferGetBlockbufferPutBlockbufferReadLine onNonClosedDoDbgdebugStreamHooksreadBlockSocketreadLineSocketwriteBlockSocketsendMainswitchResponsegetResponseHeadreadsOne headerName ifChunkeddebug httpLogFileFormVar RequestState reqDenies reqRedirects reqRetries reqStopOnDenyBAliftBSbsErrbsOut bsCookiesbsCookieFilterbsAuthorityGen bsAuthoritiesbsAllowRedirectsbsAllowBasicAuthbsConnectionPoolbsProxybsDebugbsEvent bsRequestID Challenge ChalDigestchDomainchNoncechOpaquechStale chAlgorithmchQop ChalBasicchRealmQop QopAuthIntQopAuth Algorithm AlgMD5sessAlgMD5MkCookieckDomainckNameckValueckPath ckComment ckVersion quotedstringwordcookieToHeaderheaderToCookies getCookiesForgetCookieFilterheaderToChallenge getAuthFor pickChallengeanticipateChallengechallengeToAuthority withAuthoritystringToOctetsoctetsToString base64encodekddefaultBrowserStatealterBSgetBS newRequestgetProxynullRequestStatebuildBrowserEvent reportEvent maxRetries maxDeniesrequest' spaceappend dorequest reqURIAuthlibUA