<s> import logging <EOL> from twisted . internet . protocol import ClientFactory <EOL> class ServerConnectionFactory ( ClientFactory ) : <EOL> def __init__ ( self , command , uri , postData , headers , client ) : <EOL> self . command = command <EOL> self . uri = uri <EOL> self . postData = postData <EOL> self . headers = headers <EOL> self . client = client <EOL> def buildProtocol ( self , addr ) : <EOL> return self . protocol ( self . command , self . uri , self . postData , self . headers , self . client ) <EOL> def clientConnectionFailed ( self , connector , reason ) : <EOL> logging . debug ( "<STR_LIT>" % ( self . client . getClientIP ( ) ) ) <EOL> destination = connector . getDestination ( ) <EOL> if ( destination . port != <NUM_LIT> ) : <EOL> logging . debug ( "<STR_LIT>" % ( self . client . getClientIP ( ) ) ) <EOL> self . client . proxyViaSSL ( self . headers [ '<STR_LIT:host>' ] , self . command , self . uri , self . postData , self . headers , <NUM_LIT> ) <EOL> else : <EOL> self . client . finish ( ) </s>
