aboutsummaryrefslogtreecommitdiff
path: root/scripts/async-http.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2009-04-29 17:43:21 +0000
committerRob Austein <sra@hactrn.net>2009-04-29 17:43:21 +0000
commit2c7bea62c4e8a8a25c2e0e23033d37820a9165a3 (patch)
treed2433341b14df06e8c2f52f2c7009b9fb7d8aa9f /scripts/async-http.py
parent55769ccf0d1230698646ab5afa331e7617505f4f (diff)
Doh, vhosted server really wants Host header. Handling of persistent
connections still not right, muddled logic. svn path=/scripts/async-http.py; revision=2374
Diffstat (limited to 'scripts/async-http.py')
-rw-r--r--scripts/async-http.py8
1 files changed, 3 insertions, 5 deletions
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