RES_TIMEOUT = 10 def form_get(path, host): line = '' line += 'GET ' + path + ' HTTP/1.1\r\n' line += 'Host: ' + host + '\r\n' line += 'Connection: keep-alive\r\n' line += 'Accept: text/html\r\n' line += 'Accept-Encoding: gzip\r\n' #line += 'Connection: Keep-Alive\r\n' line += '\r\n' return line s = TcpSocket() address = sys.argv[1] if address[:7] == 'http://': pass else: address = 'http://' + address o = urlparse(address) s.connect(o.netloc) path = '' foo = '' if o.path == '': path = '/' else:
def __init__(self): # define sock by the method provided by transport layer self.sock = TcpSocket() self.chunked = False self.content = '' self.header = ''