!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ % portable experimental!dominic.steinitz@blueyonder.co.uk BCut up a string into 72 char lines, each line terminated by CRLF.  portable experimental!dominic.steinitz@blueyonder.co.uk 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. 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.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.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.  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI(The Header data type pairs header names & values. JKLMNO0Inserts 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. P)Gets a list of headers with a particular . Q<Lookup presence of specific HeaderName in a list of Headers 3 Returns the value from the first matching header. RSTB !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTBIJHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"! LMOPNQRTSKB2HGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJJKLMNOPQRSTnon-portable (not tested) experimentalbjorn@bringert.netGUAn 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. VWXYZ[\]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). `abc+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. defghijklmnopqr#Parse the authority part of a URL.  RFC 1738, 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. s tASimple 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 uLike t*, but acting on an already opened stream. vw xGReceive and parse a HTTP request from the given Stream. Should be used ! for server side interactions. y"Reads and parses request headers. z>Process request body (called after successful getRequestHead) {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. |'Formats name-value pairs as application/x-www-form-urlencoded. }*Converts a single value to the application/ x-www-form-urlencoded encoding. ~"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 y  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~*s]^_`ab[UVWXYZckjihgfed\tuwxzy{}~|lmnopqvr*UVWXYZVWXYZ[\]^_`ab^_`abckjihgfeddefghijklmnopqmnopqrstuvwxyz{|}~non-portable (not tested) experimentalbjorn@bringert.neto !"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. #$%&'()*+,-./012345673Splits a list into two parts, the delimiter occurs 6 at the head of the second list. Nothing is returned . when no occurance of the delimiter is found. 8Removes delimiters. 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. 9/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. A*Asking the user to respond to a challenge B5Generating 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. C$Close all connections that are in bs' connection pool. D This should have some sort of exception handling, soldier on until C all the connections have been closed. Not sure about portability  issues. DAlter browser state EDo an io action FGHIJK696L    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTTUVWXYZ[\]^__`abcdeffghijklmnopqrsttuvwxyz{|}~         !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFG HI HTTP-3001.1.4Network.StreamNetwork.StreamDebuggerNetwork.StreamSocket Network.TCPNetwork.HTTP.Headers Network.HTTPNetwork.BrowserNetwork.HTTP.MD5AuxNetwork.HTTP.Base64Network.HTTP.MD5StreamreadLine readBlock writeBlockcloseResult ConnError ErrorMisc ErrorParse ErrorClosed ErrorResetbindEStreamDebugger debugStreamhandleSocketErrormyrecv Connection openTCPPort isConnectedTo HasHeaders getHeaders setHeaders HeaderName HdrCustomHdrContentTransferEncodingHdrLastModified HdrExpiresHdrETagHdrContentTypeHdrContentRange HdrContentMD5HdrContentLocationHdrContentLengthHdrContentLanguageHdrContentEncodingHdrContentBaseHdrAllowHdrWWWAuthenticate HdrWarningHdrVary HdrSetCookie HdrServer HdrRetryAfter HdrPublicHdrProxyAuthenticate HdrLocationHdrAge HdrUserAgent HdrRefererHdrRangeHdrProxyAuthorizationHdrMaxForwardsHdrIfUnmodifiedSince HdrIfRangeHdrIfNoneMatch HdrIfMatchHdrIfModifiedSinceHdrHostHdrFrom HdrExpect HdrCookieHdrAuthorizationHdrAcceptLanguageHdrAcceptEncodingHdrAcceptCharset HdrAcceptHdrVia HdrUpgradeHdrTransferEncoding HdrPragmaHdrDate HdrConnectionHdrCacheControlHeader headerMap insertHeaderinsertHeaderIfMissing replaceHeader insertHeadersretrieveHeaders findHeader lookupHeader parseHeader parseHeadersResponserspCode rspReason rspHeadersrspBody RequestData ResponseCodeRequestrqURIrqMethod rqHeadersrqBody RequestMethodCustomTRACEOPTIONSDELETEPOSTGETPUTHEAD URIAuthorityuserpasswordhostportparseURIAuthority httpVersion simpleHTTP simpleHTTP_getAuthsendHTTP receiveHTTPgetRequestHeadprocessRequest respondHTTP urlEncodeVars urlEncode urlDecodeForm BrowserAction BrowserStateProxyNoProxy Authority AuthDigestauNonce auAlgorithmauDomainauOpaqueauQop AuthBasicauRealm auUsername auPasswordauSiteCookieMkCookieckDomainckNameckValueckPath ckComment ckVersion uriDefaultTo uriTrimHostdefaultCookieFilteruserCookieFilter addCookie setCookies getCookiessetCookieFiltergetAuthoritiessetAuthorities addAuthoritygetAuthorityGensetAuthorityGensetAllowBasicAuthbrowseioAction setErrHandler setOutHandlerouterrsetAllowRedirectsgetAllowRedirectssetProxy setDebugLogrequestdefaultGETRequest formToRequestMD5get_nextlen_padfinishedWordListBoolListStrABCDRotationXYZZord64rotLaddmd5md5smd5imd5_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 quadrupletsencdcdencodedecodehashDbgConn ConnClosedMkConnconnSockconnAddrconnBffrconnHostConnRefgetReftrimsplitcrlf Behaviour DieHorribly ExpectEntityDoneRetryContinuebaseGHC.ShowShow ResponseDataGHC.Num*debug httpLogFilesp pURIAuthority pUserInfobefore orNothing rqMethodMapparseRequestHeadparseResponseHead matchResponseuriToAuthorityStringlinearTransferhopefulTransferchunkedTransferchunkedTransferCuglyDeathTransferreadTillEmpty1readTillEmpty2replaceFormVar RequestStateBAliftBSbsErrbsOut bsCookiesbsCookieFilterbsAuthorityGen bsAuthoritiesbsAllowRedirectsbsAllowBasicAuthbsConnectionPoolbsProxybsDebug Challenge ChalDigestchDomainchNoncechOpaquechStale chAlgorithmchQop ChalBasicchRealmQop QopAuthIntQopAuth Algorithm AlgMD5sessAlgMD5 quotedstringword splitManycookieToHeaderheaderToCookies getCookiesForgetCookieFilterheaderToChallenge getAuthFor pickChallengeanticipateChallengechallengeToAuthority withAuthorityclosePooledConnectionsalterBSgetBSgetProxyrequest'uriAuthuriAuthToStringlibUA