From 2c7bea62c4e8a8a25c2e0e23033d37820a9165a3 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 29 Apr 2009 17:43:21 +0000 Subject: Doh, vhosted server really wants Host header. Handling of persistent connections still not right, muddled logic. svn path=/scripts/async-http.py; revision=2374 --- scripts/async-http.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'scripts/async-http.py') diff --git a/scripts/async-http.py b/scripts/async-http.py index e9576cff..66c502de 100644 --- a/scripts/async-http.py +++ b/scripts/async-http.py @@ -165,7 +165,7 @@ class http_stream(asynchat.async_chat): self.handle_message() def handle_error(self): - if debug: print "[Error]" + if debug: print "[Error in HTTP stream handler]" print traceback.format_exc() asyncore.close_all() @@ -181,7 +181,6 @@ class http_server(http_stream): self.handle_message() def handle_message(self): - if debug: print "[Got message]" if debug: print "[Connection %s persistent]" % ("is" if self.msg.persistent() else "isn't") print "Query:" print self.msg @@ -218,7 +217,7 @@ class http_listener(asyncore.dispatcher): server = http_server(self.accept()[0]) def handle_error(self): - if debug: print "[Error]" + if debug: print "[Error in HTTP listener]" print traceback.format_exc() asyncore.close_all() @@ -240,7 +239,6 @@ class http_client(http_stream): self.set_terminator(None) def handle_message(self): - if debug: print "[Got message]" if debug: print "[Connection %s persistent]" % ("is" if self.msg.persistent() else "isn't") print "Query:" print self.narrator.done_msg(self.hostport) @@ -282,6 +280,7 @@ class http_narrator(object): u = urlparse.urlparse(url) assert u.scheme == "http" and u.username is None and u.password is None and u.params == "" and u.query == "" and u.fragment == "" request = http_request(cmd = "POST", path = u.path, body = body, + Host = u.hostname, Content_Type = "text/plain", Connection = "Keep-Alive" if allow_persistence else "Close") hostport = (u.hostname or "localhost", u.port or 80) @@ -300,7 +299,6 @@ class http_narrator(object): if queue and not usable: self.clients[hostport] = http_client(self, hostport) if queue and usable: - if debug: print "[Reusing existing connection]" return queue[0] else: return None -- cgit v1.2.3