some debug output in web_server.py

This commit is contained in:
Arvid Norberg 2015-01-11 07:45:06 +00:00
parent 790bdb3855
commit b56b3613fe
2 changed files with 5 additions and 3 deletions

View File

@ -108,7 +108,7 @@ class ConnectionHandler:
self.client.close() self.client.close()
return return
try: try:
if self.method=='CONNECT': if self.method == 'CONNECT':
self.method_CONNECT() self.method_CONNECT()
elif self.method in ('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', elif self.method in ('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT',
'DELETE', 'TRACE'): 'DELETE', 'TRACE'):
@ -141,7 +141,7 @@ class ConnectionHandler:
if end!=-1: if end!=-1:
break break
line_end = self.client_buffer.find('\n') line_end = self.client_buffer.find('\n')
print 'PROXY - %s'%self.client_buffer[:line_end]#debug print 'PROXY - %s' % self.client_buffer[:line_end]#debug
data = (self.client_buffer[:line_end+1]).split() data = (self.client_buffer[:line_end+1]).split()
self.client_buffer = self.client_buffer[line_end+1:] self.client_buffer = self.client_buffer[line_end+1:]
return data return data
@ -159,7 +159,7 @@ class ConnectionHandler:
host = self.path[:i] host = self.path[:i]
path = self.path[i:] path = self.path[i:]
self._connect_target(host) self._connect_target(host)
self.target.send('%s %s %s\n'%(self.method, path, self.protocol)+ self.target.send('%s %s %s\n' % (self.method, path, self.protocol)+
self.client_buffer) self.client_buffer)
self.client_buffer = '' self.client_buffer = ''
self._read_write() self._read_write()

View File

@ -140,10 +140,12 @@ class http_handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
if chunked_encoding: if chunked_encoding:
s.wfile.write('%x\r\n' % to_send) s.wfile.write('%x\r\n' % to_send)
data = f.read(to_send) data = f.read(to_send)
print 'read %d bytes' % to_send
s.wfile.write(data) s.wfile.write(data)
if chunked_encoding: if chunked_encoding:
s.wfile.write('\r\n') s.wfile.write('\r\n')
length -= to_send length -= to_send
print 'sent %d bytes (%d bytes left)' % (len(data), length)
if chunked_encoding: if chunked_encoding:
s.wfile.write('0\r\n\r\n') s.wfile.write('0\r\n\r\n')
except Exception, e: except Exception, e: