improve logging of http proxy for unit test

This commit is contained in:
Arvid Norberg 2015-01-09 14:13:19 +00:00
parent 7761cba38a
commit 790bdb3855
1 changed files with 5 additions and 5 deletions

View File

@ -102,7 +102,7 @@ class ConnectionHandler:
if username != None:
auth = base64.b64encode(username + ':' + password)
if not 'Proxy-Authorization: Basic ' + auth in self.client_buffer:
print 'failed authentication: %s' % self.client_buffer
print 'PROXY - failed authentication: %s' % self.client_buffer
self.client.send(HTTPVER+' 401 Authentication Failed\n'+
'Proxy-agent: %s\n\n'%VERSION)
self.client.close()
@ -118,7 +118,7 @@ class ConnectionHandler:
self.client.send(HTTPVER+' 502 Connection failed\n'+
'Proxy-agent: %s\n\n'%VERSION)
except Exception, e:
print e
print 'PROXY - ', e
self.client.close()
return
@ -141,7 +141,7 @@ class ConnectionHandler:
if end!=-1:
break
line_end = self.client_buffer.find('\n')
print '%s'%self.client_buffer[:line_end]#debug
print 'PROXY - %s'%self.client_buffer[:line_end]#debug
data = (self.client_buffer[:line_end+1]).split()
self.client_buffer = self.client_buffer[line_end+1:]
return data
@ -205,7 +205,7 @@ def start_server(host='localhost', port=8080, IPv6=False, timeout=100,
soc_type=socket.AF_INET
soc = socket.socket(soc_type)
soc.settimeout(120)
print "Serving on %s:%d."%(host, port)#debug
print "PROXY - Serving on %s:%d."%(host, port)#debug
soc.bind((host, port))
soc.listen(0)
while 1:
@ -225,7 +225,7 @@ if __name__ == '__main__':
password = sys.argv[i+1]
i += 1
else:
if sys.argv[i] != '--help': print('unknown option "%s"' % sys.argv[i])
if sys.argv[i] != '--help': print('PROXY - unknown option "%s"' % sys.argv[i])
print('usage: http.py [--port <listen-port>]')
sys.exit(1)
i += 1