Here are the examples of the python api Protocol.HttpProtocol taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
Example 1
def __parse_header( self, line ):
fields = line.split()
assert len( fields ) == 3, 'invalid header line: %r' % line.rstrip()
cmd, url, dummy = fields
if url.startswith( 'http://' ):
host = url[ 7: ]
port = 80
if cmd == 'GET':
proto = Protocol.HttpProtocol
else:
proto = Protocol.BlindProtocol
elif url.startswith( 'ftp://' ):
assert cmd == 'GET', '%s request unsupported for ftp' % cmd
proto = Protocol.FtpProtocol
host = url[ 6: ]
port = 21
else:
raise AssertionError, 'invalid url: %s' % url
if '/' in host:
host, path = host.split( '/', 1 )
else:
path = ''
if ':' in host:
host, port = host.split( ':' )
port = int( port )
self.cmd = cmd
self.addr = ( host, port )
self.path = path
self.cache = '%s:%i/%s' % ( host, port, path )
self.Protocol = proto