<s> """<STR_LIT>""" <EOL> from cStringIO import StringIO <EOL> import tempfile <EOL> import base64 , binascii <EOL> import cgi <EOL> import socket <EOL> import math <EOL> import time <EOL> import calendar <EOL> import warnings <EOL> import os <EOL> from urlparse import urlparse as _urlparse <EOL> from zope . interface import implements <EOL> from twisted . internet import interfaces , reactor , protocol , address <EOL> from twisted . internet . defer import Deferred <EOL> from twisted . protocols import policies , basic <EOL> from twisted . python import log <EOL> try : <EOL> from twisted . protocols . _c_urlarg import unquote <EOL> except ImportError : <EOL> from urllib import unquote <EOL> from twisted . web . http_headers import _DictHeaders , Headers <EOL> protocol_version = "<STR_LIT>" <EOL> _CONTINUE = <NUM_LIT:100> <EOL> SWITCHING = <NUM_LIT> <EOL> OK = <NUM_LIT:200> <EOL> CREATED = <NUM_LIT> <EOL> ACCEPTED = <NUM_LIT> <EOL> NON_AUTHORITATIVE_INFORMATION = <NUM_LIT> <EOL> NO_CONTENT = <NUM_LIT> <EOL> RESET_CONTENT = <NUM_LIT> <EOL> PARTIAL_CONTENT = <NUM_LIT> <EOL> MULTI_STATUS = <NUM_LIT> <EOL> MULTIPLE_CHOICE = <NUM_LIT> <EOL> MOVED_PERMANENTLY = <NUM_LIT> <EOL> FOUND = <NUM_LIT> <EOL> SEE_OTHER = <NUM_LIT> <EOL> NOT_MODIFIED = <NUM_LIT> <EOL> USE_PROXY = <NUM_LIT> <EOL> TEMPORARY_REDIRECT = <NUM_LIT> <EOL> BAD_REQUEST = <NUM_LIT> <EOL> UNAUTHORIZED = <NUM_LIT> <EOL> PAYMENT_REQUIRED = <NUM_LIT> <EOL> FORBIDDEN = <NUM_LIT> <EOL> NOT_FOUND = <NUM_LIT> <EOL> NOT_ALLOWED = <NUM_LIT> <EOL> NOT_ACCEPTABLE = <NUM_LIT> <EOL> PROXY_AUTH_REQUIRED = <NUM_LIT> <EOL> REQUEST_TIMEOUT = <NUM_LIT> <EOL> CONFLICT = <NUM_LIT> <EOL> GONE = <NUM_LIT> <EOL> LENGTH_REQUIRED = <NUM_LIT> <EOL> PRECONDITION_FAILED = <NUM_LIT> <EOL> REQUEST_ENTITY_TOO_LARGE = <NUM_LIT> <EOL> REQUEST_URI_TOO_LONG = <NUM_LIT> <EOL> UNSUPPORTED_MEDIA_TYPE = <NUM_LIT> <EOL> REQUESTED_RANGE_NOT_SATISFIABLE = <NUM_LIT> <EOL> EXPECTATION_FAILED = <NUM_LIT> <EOL> INTERNAL_SERVER_ERROR = <NUM_LIT> <EOL> NOT_IMPLEMENTED = <NUM_LIT> <EOL> BAD_GATEWAY = <NUM_LIT> <EOL> SERVICE_UNAVAILABLE = <NUM_LIT> <EOL> GATEWAY_TIMEOUT = <NUM_LIT> <EOL> HTTP_VERSION_NOT_SUPPORTED = <NUM_LIT> <EOL> INSUFFICIENT_STORAGE_SPACE = <NUM_LIT> <EOL> NOT_EXTENDED = <NUM_LIT> <EOL> RESPONSES = { <EOL> _CONTINUE : "<STR_LIT>" , <EOL> SWITCHING : "<STR_LIT>" , <EOL> OK : "<STR_LIT:OK>" , <EOL> CREATED : "<STR_LIT>" , <EOL> ACCEPTED : "<STR_LIT>" , <EOL> NON_AUTHORITATIVE_INFORMATION : "<STR_LIT>" , <EOL> NO_CONTENT : "<STR_LIT>" , <EOL> RESET_CONTENT : "<STR_LIT>" , <EOL> PARTIAL_CONTENT : "<STR_LIT>" , <EOL> MULTI_STATUS : "<STR_LIT>" , <EOL> MULTIPLE_CHOICE : "<STR_LIT>" , <EOL> MOVED_PERMANENTLY : "<STR_LIT>" , <EOL> FOUND : "<STR_LIT>" , <EOL> SEE_OTHER : "<STR_LIT>" , <EOL> NOT_MODIFIED : "<STR_LIT>" , <EOL> USE_PROXY : "<STR_LIT>" , <EOL> TEMPORARY_REDIRECT : "<STR_LIT>" , <EOL> BAD_REQUEST : "<STR_LIT>" , <EOL> UNAUTHORIZED : "<STR_LIT>" , <EOL> PAYMENT_REQUIRED : "<STR_LIT>" , <EOL> FORBIDDEN : "<STR_LIT>" , <EOL> NOT_FOUND : "<STR_LIT>" , <EOL> NOT_ALLOWED : "<STR_LIT>" , <EOL> NOT_ACCEPTABLE : "<STR_LIT>" , <EOL> PROXY_AUTH_REQUIRED : "<STR_LIT>" , <EOL> REQUEST_TIMEOUT : "<STR_LIT>" , <EOL> CONFLICT : "<STR_LIT>" , <EOL> GONE : "<STR_LIT>" , <EOL> LENGTH_REQUIRED : "<STR_LIT>" , <EOL> PRECONDITION_FAILED : "<STR_LIT>" , <EOL> REQUEST_ENTITY_TOO_LARGE : "<STR_LIT>" , <EOL> REQUEST_URI_TOO_LONG : "<STR_LIT>" , <EOL> UNSUPPORTED_MEDIA_TYPE : "<STR_LIT>" , <EOL> REQUESTED_RANGE_NOT_SATISFIABLE : "<STR_LIT>" , <EOL> EXPECTATION_FAILED : "<STR_LIT>" , <EOL> INTERNAL_SERVER_ERROR : "<STR_LIT>" , <EOL> NOT_IMPLEMENTED : "<STR_LIT>" , <EOL> BAD_GATEWAY : "<STR_LIT>" , <EOL> SERVICE_UNAVAILABLE : "<STR_LIT>" , <EOL> GATEWAY_TIMEOUT : "<STR_LIT>" , <EOL> HTTP_VERSION_NOT_SUPPORTED : "<STR_LIT>" , <EOL> INSUFFICIENT_STORAGE_SPACE : "<STR_LIT>" , <EOL> NOT_EXTENDED : "<STR_LIT>" <EOL> } <EOL> CACHED = """<STR_LIT>""" <EOL> responses = RESPONSES <EOL> weekdayname = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> monthname = [ None , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> weekdayname_lower = [ name . lower ( ) for name in weekdayname ] <EOL> monthname_lower = [ name and name . lower ( ) for name in monthname ] <EOL> def urlparse ( url ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( url , unicode ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> scheme , netloc , path , params , query , fragment = _urlparse ( url ) <EOL> if isinstance ( scheme , unicode ) : <EOL> scheme = scheme . encode ( '<STR_LIT:ascii>' ) <EOL> netloc = netloc . encode ( '<STR_LIT:ascii>' ) <EOL> path = path . encode ( '<STR_LIT:ascii>' ) <EOL> query = query . encode ( '<STR_LIT:ascii>' ) <EOL> fragment = fragment . encode ( '<STR_LIT:ascii>' ) <EOL> return scheme , netloc , path , params , query , fragment <EOL> def parse_qs ( qs , keep_blank_values = <NUM_LIT:0> , strict_parsing = <NUM_LIT:0> , unquote = unquote ) : <EOL> """<STR_LIT>""" <EOL> d = { } <EOL> items = [ s2 for s1 in qs . split ( "<STR_LIT:&>" ) for s2 in s1 . split ( "<STR_LIT:;>" ) ] <EOL> for item in items : <EOL> try : <EOL> k , v = item . split ( "<STR_LIT:=>" , <NUM_LIT:1> ) <EOL> except ValueError : <EOL> if strict_parsing : <EOL> raise <EOL> continue <EOL> if v or keep_blank_values : <EOL> k = unquote ( k . replace ( "<STR_LIT:+>" , "<STR_LIT:U+0020>" ) ) <EOL> v = unquote ( v . replace ( "<STR_LIT:+>" , "<STR_LIT:U+0020>" ) ) <EOL> if k in d : <EOL> d [ k ] . append ( v ) <EOL> else : <EOL> d [ k ] = [ v ] <EOL> return d <EOL> def datetimeToString ( msSinceEpoch = None ) : <EOL> """<STR_LIT>""" <EOL> if msSinceEpoch == None : <EOL> msSinceEpoch = time . time ( ) <EOL> year , month , day , hh , mm , ss , wd , y , z = time . gmtime ( msSinceEpoch ) <EOL> s = "<STR_LIT>" % ( <EOL> weekdayname [ wd ] , <EOL> day , monthname [ month ] , year , <EOL> hh , mm , ss ) <EOL> return s <EOL> def datetimeToLogString ( msSinceEpoch = None ) : <EOL> """<STR_LIT>""" <EOL> if msSinceEpoch == None : <EOL> msSinceEpoch = time . time ( ) <EOL> year , month , day , hh , mm , ss , wd , y , z = time . gmtime ( msSinceEpoch ) <EOL> s = "<STR_LIT>" % ( <EOL> day , monthname [ month ] , year , <EOL> hh , mm , ss ) <EOL> return s <EOL> _logDateTime = None <EOL> _logDateTimeUsers = <NUM_LIT:0> <EOL> _resetLogDateTimeID = None <EOL> def _resetLogDateTime ( ) : <EOL> global _logDateTime <EOL> global _resetLogDateTime <EOL> global _resetLogDateTimeID <EOL> _logDateTime = datetimeToLogString ( ) <EOL> _resetLogDateTimeID = reactor . callLater ( <NUM_LIT:1> , _resetLogDateTime ) <EOL> def _logDateTimeStart ( ) : <EOL> global _logDateTimeUsers <EOL> if not _logDateTimeUsers : <EOL> _resetLogDateTime ( ) <EOL> _logDateTimeUsers += <NUM_LIT:1> <EOL> def _logDateTimeStop ( ) : <EOL> global _logDateTimeUsers <EOL> _logDateTimeUsers -= <NUM_LIT:1> ; <EOL> if ( not _logDateTimeUsers and _resetLogDateTimeID <EOL> and _resetLogDateTimeID . active ( ) ) : <EOL> _resetLogDateTimeID . cancel ( ) <EOL> def timegm ( year , month , day , hour , minute , second ) : <EOL> """<STR_LIT>""" <EOL> EPOCH = <NUM_LIT> <EOL> if year < EPOCH : <EOL> raise ValueError ( "<STR_LIT>" % ( EPOCH , ) ) <EOL> assert <NUM_LIT:1> <= month <= <NUM_LIT:12> <EOL> days = <NUM_LIT> * ( year - EPOCH ) + calendar . leapdays ( EPOCH , year ) <EOL> for i in range ( <NUM_LIT:1> , month ) : <EOL> days = days + calendar . mdays [ i ] <EOL> if month > <NUM_LIT:2> and calendar . isleap ( year ) : <EOL> days = days + <NUM_LIT:1> <EOL> days = days + day - <NUM_LIT:1> <EOL> hours = days * <NUM_LIT> + hour <EOL> minutes = hours * <NUM_LIT> + minute <EOL> seconds = minutes * <NUM_LIT> + second <EOL> return seconds <EOL> def stringToDatetime ( dateString ) : <EOL> """<STR_LIT>""" <EOL> parts = dateString . split ( ) <EOL> if not parts [ <NUM_LIT:0> ] [ <NUM_LIT:0> : <NUM_LIT:3> ] . lower ( ) in weekdayname_lower : <EOL> try : <EOL> return stringToDatetime ( "<STR_LIT>" + dateString ) <EOL> except ValueError : <EOL> pass <EOL> partlen = len ( parts ) <EOL> if ( partlen == <NUM_LIT:5> or partlen == <NUM_LIT:6> ) and parts [ <NUM_LIT:1> ] . isdigit ( ) : <EOL> day = parts [ <NUM_LIT:1> ] <EOL> month = parts [ <NUM_LIT:2> ] <EOL> year = parts [ <NUM_LIT:3> ] <EOL> time = parts [ <NUM_LIT:4> ] <EOL> elif ( partlen == <NUM_LIT:3> or partlen == <NUM_LIT:4> ) and parts [ <NUM_LIT:1> ] . find ( '<STR_LIT:->' ) != - <NUM_LIT:1> : <EOL> day , month , year = parts [ <NUM_LIT:1> ] . split ( '<STR_LIT:->' ) <EOL> time = parts [ <NUM_LIT:2> ] <EOL> year = int ( year ) <EOL> if year < <NUM_LIT> : <EOL> year = year + <NUM_LIT> <EOL> elif year < <NUM_LIT:100> : <EOL> year = year + <NUM_LIT> <EOL> elif len ( parts ) == <NUM_LIT:5> : <EOL> day = parts [ <NUM_LIT:2> ] <EOL> month = parts [ <NUM_LIT:1> ] <EOL> year = parts [ <NUM_LIT:4> ] <EOL> time = parts [ <NUM_LIT:3> ] <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" % dateString ) <EOL> day = int ( day ) <EOL> month = int ( monthname_lower . index ( month . lower ( ) ) ) <EOL> year = int ( year ) <EOL> hour , min , sec = map ( int , time . split ( '<STR_LIT::>' ) ) <EOL> return int ( timegm ( year , month , day , hour , min , sec ) ) <EOL> def toChunk ( data ) : <EOL> """<STR_LIT>""" <EOL> return ( "<STR_LIT>" % len ( data ) , data , "<STR_LIT:\r\n>" ) <EOL> def fromChunk ( data ) : <EOL> """<STR_LIT>""" <EOL> prefix , rest = data . split ( '<STR_LIT:\r\n>' , <NUM_LIT:1> ) <EOL> length = int ( prefix , <NUM_LIT:16> ) <EOL> if length < <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" % ( length , ) ) <EOL> if not rest [ length : length + <NUM_LIT:2> ] == '<STR_LIT:\r\n>' : <EOL> raise ValueError , "<STR_LIT>" <EOL> return rest [ : length ] , rest [ length + <NUM_LIT:2> : ] <EOL> def parseContentRange ( header ) : <EOL> """<STR_LIT>""" <EOL> kind , other = header . strip ( ) . split ( ) <EOL> if kind . lower ( ) != "<STR_LIT>" : <EOL> raise ValueError , "<STR_LIT>" <EOL> startend , realLength = other . split ( "<STR_LIT:/>" ) <EOL> start , end = map ( int , startend . split ( "<STR_LIT:->" ) ) <EOL> if realLength == "<STR_LIT:*>" : <EOL> realLength = None <EOL> else : <EOL> realLength = int ( realLength ) <EOL> return ( start , end , realLength ) <EOL> class StringTransport : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . s = StringIO ( ) <EOL> def writeSequence ( self , seq ) : <EOL> self . s . write ( '<STR_LIT>' . join ( seq ) ) <EOL> def __getattr__ ( self , attr ) : <EOL> return getattr ( self . __dict__ [ '<STR_LIT:s>' ] , attr ) <EOL> class HTTPClient ( basic . LineReceiver ) : <EOL> """<STR_LIT>""" <EOL> length = None <EOL> firstLine = True <EOL> __buffer = None <EOL> _header = "<STR_LIT>" <EOL> def sendCommand ( self , command , path ) : <EOL> self . transport . write ( '<STR_LIT>' % ( command , path ) ) <EOL> def sendHeader ( self , name , value ) : <EOL> self . transport . write ( '<STR_LIT>' % ( name , value ) ) <EOL> def endHeaders ( self ) : <EOL> self . transport . write ( '<STR_LIT:\r\n>' ) <EOL> def extractHeader ( self , header ) : <EOL> """<STR_LIT>""" <EOL> key , val = header . split ( '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> val = val . lstrip ( ) <EOL> self . handleHeader ( key , val ) <EOL> if key . lower ( ) == '<STR_LIT>' : <EOL> self . length = int ( val ) <EOL> def lineReceived ( self , line ) : <EOL> """<STR_LIT>""" <EOL> if self . firstLine : <EOL> self . firstLine = False <EOL> l = line . split ( None , <NUM_LIT:2> ) <EOL> version = l [ <NUM_LIT:0> ] <EOL> status = l [ <NUM_LIT:1> ] <EOL> try : <EOL> message = l [ <NUM_LIT:2> ] <EOL> except IndexError : <EOL> message = "<STR_LIT>" <EOL> self . handleStatus ( version , status , message ) <EOL> return <EOL> if not line : <EOL> if self . _header != "<STR_LIT>" : <EOL> self . extractHeader ( self . _header ) <EOL> self . __buffer = StringIO ( ) <EOL> self . handleEndHeaders ( ) <EOL> self . setRawMode ( ) <EOL> return <EOL> if line . startswith ( '<STR_LIT:\t>' ) or line . startswith ( '<STR_LIT:U+0020>' ) : <EOL> self . _header = self . _header + line <EOL> elif self . _header : <EOL> self . extractHeader ( self . _header ) <EOL> self . _header = line <EOL> else : <EOL> self . _header = line <EOL> def connectionLost ( self , reason ) : <EOL> self . handleResponseEnd ( ) <EOL> def handleResponseEnd ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __buffer is not None : <EOL> b = self . __buffer . getvalue ( ) <EOL> self . __buffer = None <EOL> self . handleResponse ( b ) <EOL> def handleResponsePart ( self , data ) : <EOL> self . __buffer . write ( data ) <EOL> def connectionMade ( self ) : <EOL> pass <EOL> def handleStatus ( self , version , status , message ) : <EOL> """<STR_LIT>""" <EOL> def handleHeader ( self , key , val ) : <EOL> """<STR_LIT>""" <EOL> def handleEndHeaders ( self ) : <EOL> """<STR_LIT>""" <EOL> def rawDataReceived ( self , data ) : <EOL> if self . length is not None : <EOL> data , rest = data [ : self . length ] , data [ self . length : ] <EOL> self . length -= len ( data ) <EOL> else : <EOL> rest = '<STR_LIT>' <EOL> self . handleResponsePart ( data ) <EOL> if self . length == <NUM_LIT:0> : <EOL> self . handleResponseEnd ( ) <EOL> self . setLineMode ( rest ) <EOL> NO_BODY_CODES = ( <NUM_LIT> , <NUM_LIT> ) <EOL> class Request : <EOL> """<STR_LIT>""" <EOL> implements ( interfaces . IConsumer ) <EOL> producer = None <EOL> finished = <NUM_LIT:0> <EOL> code = OK <EOL> code_message = RESPONSES [ OK ] <EOL> method = "<STR_LIT>" <EOL> clientproto = "<STR_LIT>" <EOL> uri = "<STR_LIT>" <EOL> startedWriting = <NUM_LIT:0> <EOL> chunked = <NUM_LIT:0> <EOL> sentLength = <NUM_LIT:0> <EOL> etag = None <EOL> lastModified = None <EOL> args = None <EOL> path = None <EOL> content = None <EOL> _forceSSL = <NUM_LIT:0> <EOL> _disconnected = False <EOL> def __init__ ( self , channel , queued ) : <EOL> """<STR_LIT>""" <EOL> self . notifications = [ ] <EOL> self . channel = channel <EOL> self . queued = queued <EOL> self . requestHeaders = Headers ( ) <EOL> self . received_cookies = { } <EOL> self . responseHeaders = Headers ( ) <EOL> self . cookies = [ ] <EOL> if queued : <EOL> self . transport = StringTransport ( ) <EOL> else : <EOL> self . transport = self . channel . transport <EOL> def __setattr__ ( self , name , value ) : <EOL> """<STR_LIT>""" <EOL> if name == '<STR_LIT>' : <EOL> self . requestHeaders = headers = Headers ( ) <EOL> for k , v in value . iteritems ( ) : <EOL> headers . setRawHeaders ( k , [ v ] ) <EOL> elif name == '<STR_LIT>' : <EOL> self . __dict__ [ name ] = value <EOL> self . __dict__ [ '<STR_LIT>' ] = _DictHeaders ( value ) <EOL> elif name == '<STR_LIT>' : <EOL> self . responseHeaders = headers = Headers ( ) <EOL> for k , v in value . iteritems ( ) : <EOL> headers . setRawHeaders ( k , [ v ] ) <EOL> elif name == '<STR_LIT>' : <EOL> self . __dict__ [ name ] = value <EOL> self . __dict__ [ '<STR_LIT>' ] = _DictHeaders ( value ) <EOL> else : <EOL> self . __dict__ [ name ] = value <EOL> def _cleanup ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . producer : <EOL> log . err ( RuntimeError ( "<STR_LIT>" % self . uri ) ) <EOL> self . unregisterProducer ( ) <EOL> self . channel . requestDone ( self ) <EOL> del self . channel <EOL> try : <EOL> self . content . close ( ) <EOL> except OSError : <EOL> pass <EOL> del self . content <EOL> for d in self . notifications : <EOL> d . callback ( None ) <EOL> self . notifications = [ ] <EOL> def noLongerQueued ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . queued : <EOL> raise RuntimeError , "<STR_LIT>" <EOL> self . queued = <NUM_LIT:0> <EOL> data = self . transport . getvalue ( ) <EOL> self . transport = self . channel . transport <EOL> if data : <EOL> self . transport . write ( data ) <EOL> if ( self . producer is not None ) and not self . finished : <EOL> self . transport . registerProducer ( self . producer , self . streamingProducer ) <EOL> if self . finished : <EOL> self . _cleanup ( ) <EOL> def gotLength ( self , length ) : <EOL> """<STR_LIT>""" <EOL> if length is not None and length < <NUM_LIT> : <EOL> self . content = StringIO ( ) <EOL> else : <EOL> self . content = tempfile . TemporaryFile ( ) <EOL> def parseCookies ( self ) : <EOL> """<STR_LIT>""" <EOL> cookieheaders = self . requestHeaders . getRawHeaders ( "<STR_LIT>" ) <EOL> if cookieheaders is None : <EOL> return <EOL> for cookietxt in cookieheaders : <EOL> if cookietxt : <EOL> for cook in cookietxt . split ( '<STR_LIT:;>' ) : <EOL> cook = cook . lstrip ( ) <EOL> try : <EOL> k , v = cook . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> self . received_cookies [ k ] = v <EOL> except ValueError : <EOL> pass <EOL> def handleContentChunk ( self , data ) : <EOL> """<STR_LIT>""" <EOL> self . content . write ( data ) <EOL> def requestReceived ( self , command , path , version ) : <EOL> """<STR_LIT>""" <EOL> self . content . seek ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . args = { } <EOL> self . stack = [ ] <EOL> self . method , self . uri = command , path <EOL> self . clientproto = version <EOL> x = self . uri . split ( '<STR_LIT:?>' , <NUM_LIT:1> ) <EOL> if len ( x ) == <NUM_LIT:1> : <EOL> self . path = self . uri <EOL> else : <EOL> self . path , argstring = x <EOL> self . args = parse_qs ( argstring , <NUM_LIT:1> ) <EOL> self . client = self . channel . transport . getPeer ( ) <EOL> self . host = self . channel . transport . getHost ( ) <EOL> args = self . args <EOL> ctype = self . requestHeaders . getRawHeaders ( '<STR_LIT>' ) <EOL> if ctype is not None : <EOL> ctype = ctype [ <NUM_LIT:0> ] <EOL> if self . method == "<STR_LIT:POST>" and ctype : <EOL> mfd = '<STR_LIT>' <EOL> key , pdict = cgi . parse_header ( ctype ) <EOL> if key == '<STR_LIT>' : <EOL> args . update ( parse_qs ( self . content . read ( ) , <NUM_LIT:1> ) ) <EOL> elif key == mfd : <EOL> try : <EOL> args . update ( cgi . parse_multipart ( self . content , pdict ) ) <EOL> except KeyError , e : <EOL> if e . args [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> self . channel . transport . write ( <EOL> "<STR_LIT>" ) <EOL> self . channel . transport . loseConnection ( ) <EOL> return <EOL> raise <EOL> self . content . seek ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . process ( ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . method , self . uri , self . clientproto ) <EOL> def process ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def registerProducer ( self , producer , streaming ) : <EOL> """<STR_LIT>""" <EOL> if self . producer : <EOL> raise ValueError , "<STR_LIT>" % ( producer , self . producer ) <EOL> self . streamingProducer = streaming <EOL> self . producer = producer <EOL> if self . queued : <EOL> if streaming : <EOL> producer . pauseProducing ( ) <EOL> else : <EOL> self . transport . registerProducer ( producer , streaming ) <EOL> def unregisterProducer ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . queued : <EOL> self . transport . unregisterProducer ( ) <EOL> self . producer = None <EOL> def _sendError ( self , code , resp = '<STR_LIT>' ) : <EOL> self . transport . write ( '<STR_LIT>' % ( self . clientproto , code , resp ) ) <EOL> def getHeader ( self , key ) : <EOL> """<STR_LIT>""" <EOL> value = self . requestHeaders . getRawHeaders ( key ) <EOL> if value is not None : <EOL> return value [ - <NUM_LIT:1> ] <EOL> def getCookie ( self , key ) : <EOL> """<STR_LIT>""" <EOL> return self . received_cookies . get ( key ) <EOL> def notifyFinish ( self ) : <EOL> """<STR_LIT>""" <EOL> self . notifications . append ( Deferred ( ) ) <EOL> return self . notifications [ - <NUM_LIT:1> ] <EOL> def finish ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _disconnected : <EOL> raise RuntimeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if self . finished : <EOL> warnings . warn ( "<STR_LIT>" , stacklevel = <NUM_LIT:2> ) <EOL> return <EOL> if not self . startedWriting : <EOL> self . write ( '<STR_LIT>' ) <EOL> if self . chunked : <EOL> self . transport . write ( "<STR_LIT>" ) <EOL> if hasattr ( self . channel , "<STR_LIT>" ) : <EOL> self . channel . factory . log ( self ) <EOL> self . finished = <NUM_LIT:1> <EOL> if not self . queued : <EOL> self . _cleanup ( ) <EOL> def write ( self , data ) : <EOL> """<STR_LIT>""" <EOL> if not self . startedWriting : <EOL> self . startedWriting = <NUM_LIT:1> <EOL> version = self . clientproto <EOL> l = [ ] <EOL> l . append ( '<STR_LIT>' % ( version , self . code , <EOL> self . code_message ) ) <EOL> if ( ( version == "<STR_LIT>" ) and <EOL> ( self . responseHeaders . getRawHeaders ( '<STR_LIT>' ) is None ) and <EOL> self . method != "<STR_LIT>" and self . code not in NO_BODY_CODES ) : <EOL> l . append ( "<STR_LIT>" % ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . chunked = <NUM_LIT:1> <EOL> if self . lastModified is not None : <EOL> if self . responseHeaders . hasHeader ( '<STR_LIT>' ) : <EOL> log . msg ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> self . responseHeaders . setRawHeaders ( <EOL> '<STR_LIT>' , <EOL> [ datetimeToString ( self . lastModified ) ] ) <EOL> if self . etag is not None : <EOL> self . responseHeaders . setRawHeaders ( '<STR_LIT>' , [ self . etag ] ) <EOL> for name , values in self . responseHeaders . getAllRawHeaders ( ) : <EOL> for value in values : <EOL> l . append ( "<STR_LIT>" % ( name , value ) ) <EOL> for cookie in self . cookies : <EOL> l . append ( '<STR_LIT>' % ( "<STR_LIT>" , cookie ) ) <EOL> l . append ( "<STR_LIT:\r\n>" ) <EOL> self . transport . writeSequence ( l ) <EOL> if self . method == "<STR_LIT>" : <EOL> self . write = lambda data : None <EOL> return <EOL> if self . code in NO_BODY_CODES : <EOL> self . write = lambda data : None <EOL> return <EOL> self . sentLength = self . sentLength + len ( data ) <EOL> if data : <EOL> if self . chunked : <EOL> self . transport . writeSequence ( toChunk ( data ) ) <EOL> else : <EOL> self . transport . write ( data ) <EOL> def addCookie ( self , k , v , expires = None , domain = None , path = None , max_age = None , comment = None , secure = None ) : <EOL> """<STR_LIT>""" <EOL> cookie = '<STR_LIT>' % ( k , v ) <EOL> if expires is not None : <EOL> cookie = cookie + "<STR_LIT>" % expires <EOL> if domain is not None : <EOL> cookie = cookie + "<STR_LIT>" % domain <EOL> if path is not None : <EOL> cookie = cookie + "<STR_LIT>" % path <EOL> if max_age is not None : <EOL> cookie = cookie + "<STR_LIT>" % max_age <EOL> if comment is not None : <EOL> cookie = cookie + "<STR_LIT>" % comment <EOL> if secure : <EOL> cookie = cookie + "<STR_LIT>" <EOL> self . cookies . append ( cookie ) <EOL> def setResponseCode ( self , code , message = None ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( code , ( int , long ) ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> self . code = code <EOL> if message : <EOL> self . code_message = message <EOL> else : <EOL> self . code_message = RESPONSES . get ( code , "<STR_LIT>" ) <EOL> def setHeader ( self , name , value ) : <EOL> """<STR_LIT>""" <EOL> self . responseHeaders . setRawHeaders ( name , [ value ] ) <EOL> def redirect ( self , url ) : <EOL> """<STR_LIT>""" <EOL> self . setResponseCode ( FOUND ) <EOL> self . setHeader ( "<STR_LIT:location>" , url ) <EOL> def setLastModified ( self , when ) : <EOL> """<STR_LIT>""" <EOL> when = long ( math . ceil ( when ) ) <EOL> if ( not self . lastModified ) or ( self . lastModified < when ) : <EOL> self . lastModified = when <EOL> modifiedSince = self . getHeader ( '<STR_LIT>' ) <EOL> if modifiedSince : <EOL> firstPart = modifiedSince . split ( '<STR_LIT:;>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> try : <EOL> modifiedSince = stringToDatetime ( firstPart ) <EOL> except ValueError : <EOL> return None <EOL> if modifiedSince >= when : <EOL> self . setResponseCode ( NOT_MODIFIED ) <EOL> return CACHED <EOL> return None <EOL> def setETag ( self , etag ) : <EOL> """<STR_LIT>""" <EOL> if etag : <EOL> self . etag = etag <EOL> tags = self . getHeader ( "<STR_LIT>" ) <EOL> if tags : <EOL> tags = tags . split ( ) <EOL> if ( etag in tags ) or ( '<STR_LIT:*>' in tags ) : <EOL> self . setResponseCode ( ( ( self . method in ( "<STR_LIT>" , "<STR_LIT:GET>" ) ) <EOL> and NOT_MODIFIED ) <EOL> or PRECONDITION_FAILED ) <EOL> return CACHED <EOL> return None <EOL> def getAllHeaders ( self ) : <EOL> """<STR_LIT>""" <EOL> headers = { } <EOL> for k , v in self . requestHeaders . getAllRawHeaders ( ) : <EOL> headers [ k . lower ( ) ] = v [ - <NUM_LIT:1> ] <EOL> return headers <EOL> def getRequestHostname ( self ) : <EOL> """<STR_LIT>""" <EOL> host = self . getHeader ( '<STR_LIT:host>' ) <EOL> if host : <EOL> return host . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> return self . getHost ( ) . host <EOL> def getHost ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . host <EOL> def setHost ( self , host , port , ssl = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> self . _forceSSL = ssl <EOL> self . requestHeaders . setRawHeaders ( "<STR_LIT:host>" , [ host ] ) <EOL> self . host = address . IPv4Address ( "<STR_LIT>" , host , port ) <EOL> def getClientIP ( self ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( self . client , address . IPv4Address ) : <EOL> return self . client . host <EOL> else : <EOL> return None <EOL> def isSecure ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _forceSSL : <EOL> return True <EOL> transport = getattr ( getattr ( self , '<STR_LIT>' , None ) , '<STR_LIT>' , None ) <EOL> if interfaces . ISSLTransport ( transport , None ) is not None : <EOL> return True <EOL> return False <EOL> def _authorize ( self ) : <EOL> try : <EOL> authh = self . getHeader ( "<STR_LIT>" ) <EOL> if not authh : <EOL> self . user = self . password = '<STR_LIT>' <EOL> return <EOL> bas , upw = authh . split ( ) <EOL> if bas . lower ( ) != "<STR_LIT>" : <EOL> raise ValueError <EOL> upw = base64 . decodestring ( upw ) <EOL> self . user , self . password = upw . split ( '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> except ( binascii . Error , ValueError ) : <EOL> self . user = self . password = "<STR_LIT>" <EOL> except : <EOL> log . err ( ) <EOL> self . user = self . password = "<STR_LIT>" <EOL> def getUser ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . user <EOL> except : <EOL> pass <EOL> self . _authorize ( ) <EOL> return self . user <EOL> def getPassword ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . password <EOL> except : <EOL> pass <EOL> self . _authorize ( ) <EOL> return self . password <EOL> def getClient ( self ) : <EOL> if self . client . type != '<STR_LIT>' : <EOL> return None <EOL> host = self . client . host <EOL> try : <EOL> name , names , addresses = socket . gethostbyaddr ( host ) <EOL> except socket . error : <EOL> return host <EOL> names . insert ( <NUM_LIT:0> , name ) <EOL> for name in names : <EOL> if '<STR_LIT:.>' in name : <EOL> return name <EOL> return names [ <NUM_LIT:0> ] <EOL> def connectionLost ( self , reason ) : <EOL> """<STR_LIT>""" <EOL> self . _disconnected = True <EOL> self . channel = None <EOL> if self . content is not None : <EOL> self . content . close ( ) <EOL> for d in self . notifications : <EOL> d . errback ( reason ) <EOL> self . notifications = [ ] <EOL> class _DataLoss ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class PotentialDataLoss ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class _IdentityTransferDecoder ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , contentLength , dataCallback , finishCallback ) : <EOL> self . contentLength = contentLength <EOL> self . dataCallback = dataCallback <EOL> self . finishCallback = finishCallback <EOL> def dataReceived ( self , data ) : <EOL> """<STR_LIT>""" <EOL> if self . dataCallback is None : <EOL> raise RuntimeError ( <EOL> "<STR_LIT>" ) <EOL> if self . contentLength is None : <EOL> self . dataCallback ( data ) <EOL> elif len ( data ) < self . contentLength : <EOL> self . contentLength -= len ( data ) <EOL> self . dataCallback ( data ) <EOL> else : <EOL> contentLength = self . contentLength <EOL> dataCallback = self . dataCallback <EOL> finishCallback = self . finishCallback <EOL> self . dataCallback = self . finishCallback = None <EOL> self . contentLength = <NUM_LIT:0> <EOL> dataCallback ( data [ : contentLength ] ) <EOL> finishCallback ( data [ contentLength : ] ) <EOL> def noMoreData ( self ) : <EOL> """<STR_LIT>""" <EOL> finishCallback = self . finishCallback <EOL> self . dataCallback = self . finishCallback = None <EOL> if self . contentLength is None : <EOL> finishCallback ( '<STR_LIT>' ) <EOL> raise PotentialDataLoss ( ) <EOL> elif self . contentLength != <NUM_LIT:0> : <EOL> raise _DataLoss ( ) <EOL> class _ChunkedTransferDecoder ( object ) : <EOL> """<STR_LIT>""" <EOL> state = '<STR_LIT>' <EOL> finish = False <EOL> def __init__ ( self , dataCallback , finishCallback ) : <EOL> self . dataCallback = dataCallback <EOL> self . finishCallback = finishCallback <EOL> self . _buffer = '<STR_LIT>' <EOL> def dataReceived ( self , data ) : <EOL> """<STR_LIT>""" <EOL> data = self . _buffer + data <EOL> self . _buffer = '<STR_LIT>' <EOL> while data : <EOL> if self . state == '<STR_LIT>' : <EOL> if '<STR_LIT:\r\n>' in data : <EOL> line , rest = data . split ( '<STR_LIT:\r\n>' , <NUM_LIT:1> ) <EOL> parts = line . split ( '<STR_LIT:;>' ) <EOL> self . length = int ( parts [ <NUM_LIT:0> ] , <NUM_LIT:16> ) <EOL> if self . length == <NUM_LIT:0> : <EOL> self . state = '<STR_LIT>' <EOL> self . finish = True <EOL> else : <EOL> self . state = '<STR_LIT:body>' <EOL> data = rest <EOL> else : <EOL> self . _buffer = data <EOL> data = '<STR_LIT>' <EOL> elif self . state == '<STR_LIT>' : <EOL> if data . startswith ( '<STR_LIT:\r\n>' ) : <EOL> data = data [ <NUM_LIT:2> : ] <EOL> if self . finish : <EOL> self . state = '<STR_LIT>' <EOL> self . finishCallback ( data ) <EOL> data = '<STR_LIT>' <EOL> else : <EOL> self . state = '<STR_LIT>' <EOL> else : <EOL> self . _buffer = data <EOL> data = '<STR_LIT>' <EOL> elif self . state == '<STR_LIT:body>' : <EOL> if len ( data ) >= self . length : <EOL> chunk , data = data [ : self . length ] , data [ self . length : ] <EOL> self . dataCallback ( chunk ) <EOL> self . state = '<STR_LIT>' <EOL> elif len ( data ) < self . length : <EOL> self . length -= len ( data ) <EOL> self . dataCallback ( data ) <EOL> data = '<STR_LIT>' <EOL> elif self . state == '<STR_LIT>' : <EOL> raise RuntimeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def noMoreData ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . state != '<STR_LIT>' : <EOL> raise _DataLoss ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( self . state , ) ) <EOL> class HTTPChannel ( basic . LineReceiver , policies . TimeoutMixin ) : <EOL> """<STR_LIT>""" <EOL> maxHeaders = <NUM_LIT> <EOL> length = <NUM_LIT:0> <EOL> persistent = <NUM_LIT:1> <EOL> __header = '<STR_LIT>' <EOL> __first_line = <NUM_LIT:1> <EOL> __content = None <EOL> requestFactory = Request <EOL> _savedTimeOut = None <EOL> _receivedHeaderCount = <NUM_LIT:0> <EOL> def __init__ ( self ) : <EOL> self . requests = [ ] <EOL> self . _transferDecoder = None <EOL> def connectionMade ( self ) : <EOL> self . setTimeout ( self . timeOut ) <EOL> def lineReceived ( self , line ) : <EOL> self . resetTimeout ( ) <EOL> if self . __first_line : <EOL> if not self . persistent : <EOL> self . dataReceived = self . lineReceived = lambda * args : None <EOL> return <EOL> if not line and self . __first_line == <NUM_LIT:1> : <EOL> self . __first_line = <NUM_LIT:2> <EOL> return <EOL> request = self . requestFactory ( self , len ( self . requests ) ) <EOL> self . requests . append ( request ) <EOL> self . __first_line = <NUM_LIT:0> <EOL> parts = line . split ( ) <EOL> if len ( parts ) != <NUM_LIT:3> : <EOL> self . transport . write ( "<STR_LIT>" ) <EOL> self . transport . loseConnection ( ) <EOL> return <EOL> command , request , version = parts <EOL> self . _command = command <EOL> self . _path = request <EOL> self . _version = version <EOL> elif line == '<STR_LIT>' : <EOL> if self . __header : <EOL> self . headerReceived ( self . __header ) <EOL> self . __header = '<STR_LIT>' <EOL> self . allHeadersReceived ( ) <EOL> if self . length == <NUM_LIT:0> : <EOL> self . allContentReceived ( ) <EOL> else : <EOL> self . setRawMode ( ) <EOL> elif line [ <NUM_LIT:0> ] in '<STR_LIT>' : <EOL> self . __header = self . __header + '<STR_LIT:\n>' + line <EOL> else : <EOL> if self . __header : <EOL> self . headerReceived ( self . __header ) <EOL> self . __header = line <EOL> def _finishRequestBody ( self , data ) : <EOL> self . allContentReceived ( ) <EOL> self . setLineMode ( data ) <EOL> def headerReceived ( self , line ) : <EOL> """<STR_LIT>""" <EOL> header , data = line . split ( '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> header = header . lower ( ) <EOL> data = data . strip ( ) <EOL> if header == '<STR_LIT>' : <EOL> self . length = int ( data ) <EOL> self . _transferDecoder = _IdentityTransferDecoder ( <EOL> self . length , self . requests [ - <NUM_LIT:1> ] . handleContentChunk , self . _finishRequestBody ) <EOL> elif header == '<STR_LIT>' and data . lower ( ) == '<STR_LIT>' : <EOL> self . length = None <EOL> self . _transferDecoder = _ChunkedTransferDecoder ( <EOL> self . requests [ - <NUM_LIT:1> ] . handleContentChunk , self . _finishRequestBody ) <EOL> reqHeaders = self . requests [ - <NUM_LIT:1> ] . requestHeaders <EOL> values = reqHeaders . getRawHeaders ( header ) <EOL> if values is not None : <EOL> values . append ( data ) <EOL> else : <EOL> reqHeaders . setRawHeaders ( header , [ data ] ) <EOL> self . _receivedHeaderCount += <NUM_LIT:1> <EOL> if self . _receivedHeaderCount > self . maxHeaders : <EOL> self . transport . write ( "<STR_LIT>" ) <EOL> self . transport . loseConnection ( ) <EOL> def allContentReceived ( self ) : <EOL> command = self . _command <EOL> path = self . _path <EOL> version = self . _version <EOL> self . length = <NUM_LIT:0> <EOL> self . _receivedHeaderCount = <NUM_LIT:0> <EOL> self . __first_line = <NUM_LIT:1> <EOL> self . _transferDecoder = None <EOL> del self . _command , self . _path , self . _version <EOL> if self . timeOut : <EOL> self . _savedTimeOut = self . setTimeout ( None ) <EOL> req = self . requests [ - <NUM_LIT:1> ] <EOL> req . requestReceived ( command , path , version ) <EOL> def rawDataReceived ( self , data ) : <EOL> self . resetTimeout ( ) <EOL> self . _transferDecoder . dataReceived ( data ) <EOL> def allHeadersReceived ( self ) : <EOL> req = self . requests [ - <NUM_LIT:1> ] <EOL> req . parseCookies ( ) <EOL> self . persistent = self . checkPersistence ( req , self . _version ) <EOL> req . gotLength ( self . length ) <EOL> def checkPersistence ( self , request , version ) : <EOL> """<STR_LIT>""" <EOL> connection = request . requestHeaders . getRawHeaders ( '<STR_LIT>' ) <EOL> if connection : <EOL> tokens = map ( str . lower , connection [ <NUM_LIT:0> ] . split ( '<STR_LIT:U+0020>' ) ) <EOL> else : <EOL> tokens = [ ] <EOL> if version == "<STR_LIT>" : <EOL> if '<STR_LIT>' in tokens : <EOL> request . responseHeaders . setRawHeaders ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> return False <EOL> else : <EOL> return True <EOL> else : <EOL> return False <EOL> def requestDone ( self , request ) : <EOL> """<STR_LIT>""" <EOL> if request != self . requests [ <NUM_LIT:0> ] : raise TypeError <EOL> del self . requests [ <NUM_LIT:0> ] <EOL> if self . persistent : <EOL> if self . requests : <EOL> self . requests [ <NUM_LIT:0> ] . noLongerQueued ( ) <EOL> else : <EOL> if self . _savedTimeOut : <EOL> self . setTimeout ( self . _savedTimeOut ) <EOL> else : <EOL> self . transport . loseConnection ( ) <EOL> def timeoutConnection ( self ) : <EOL> log . msg ( "<STR_LIT>" % str ( self . transport . getPeer ( ) ) ) <EOL> policies . TimeoutMixin . timeoutConnection ( self ) <EOL> def connectionLost ( self , reason ) : <EOL> self . setTimeout ( None ) <EOL> for request in self . requests : <EOL> request . connectionLost ( reason ) <EOL> class HTTPFactory ( protocol . ServerFactory ) : <EOL> """<STR_LIT>""" <EOL> protocol = HTTPChannel <EOL> logPath = None <EOL> timeOut = <NUM_LIT> * <NUM_LIT> * <NUM_LIT:12> <EOL> def __init__ ( self , logPath = None , timeout = <NUM_LIT> * <NUM_LIT> * <NUM_LIT:12> ) : <EOL> if logPath is not None : <EOL> logPath = os . path . abspath ( logPath ) <EOL> self . logPath = logPath <EOL> self . timeOut = timeout <EOL> def buildProtocol ( self , addr ) : <EOL> p = protocol . ServerFactory . buildProtocol ( self , addr ) <EOL> p . timeOut = self . timeOut <EOL> return p <EOL> def startFactory ( self ) : <EOL> _logDateTimeStart ( ) <EOL> if self . logPath : <EOL> self . logFile = self . _openLogFile ( self . logPath ) <EOL> else : <EOL> self . logFile = log . logfile <EOL> def stopFactory ( self ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> if self . logFile != log . logfile : <EOL> self . logFile . close ( ) <EOL> del self . logFile <EOL> _logDateTimeStop ( ) <EOL> def _openLogFile ( self , path ) : <EOL> """<STR_LIT>""" <EOL> f = open ( path , "<STR_LIT:a>" , <NUM_LIT:1> ) <EOL> return f <EOL> def _escape ( self , s ) : <EOL> r = repr ( s ) <EOL> if r [ <NUM_LIT:0> ] == "<STR_LIT:'>" : <EOL> return r [ <NUM_LIT:1> : - <NUM_LIT:1> ] . replace ( '<STR_LIT:">' , '<STR_LIT>' ) . replace ( "<STR_LIT>" , "<STR_LIT:'>" ) <EOL> return r [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> def log ( self , request ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> line = '<STR_LIT>' % ( <EOL> request . getClientIP ( ) , <EOL> _logDateTime , <EOL> '<STR_LIT>' % ( self . _escape ( request . method ) , <EOL> self . _escape ( request . uri ) , <EOL> self . _escape ( request . clientproto ) ) , <EOL> request . code , <EOL> request . sentLength or "<STR_LIT:->" , <EOL> self . _escape ( request . getHeader ( "<STR_LIT>" ) or "<STR_LIT:->" ) , <EOL> self . _escape ( request . getHeader ( "<STR_LIT>" ) or "<STR_LIT:->" ) ) <EOL> self . logFile . write ( line ) </s>
