diff options
author | Rob Austein <sra@hactrn.net> | 2009-05-03 20:53:45 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2009-05-03 20:53:45 +0000 |
commit | 4b31f400f6509bb26c390d688fa47eba73e7a3cb (patch) | |
tree | b54f5b6d221378f8a45cacead3f6b1506d619c80 /scripts | |
parent | f7fe04d7a2822090a5b350fbba3e08372fb169ff (diff) |
Cleanup
svn path=/scripts/async-http.py; revision=2393
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/async-http.py | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/scripts/async-http.py b/scripts/async-http.py index 66cd000e..47412d94 100644 --- a/scripts/async-http.py +++ b/scripts/async-http.py @@ -343,16 +343,6 @@ class http_listener(asyncore.dispatcher): print traceback.format_exc() asyncore.close_all() -# Might need to know whether outbound data is fully sent, as part of -# this state thing. If so, calling .writable() ought to do the trick, -# so long as it has no side effects (need to check asynchat.py for -# that). -# -# I don't think there's anything we can do about crossed-in-mail -# problem where we finish sending query just as server sends us -# an unsolicited message. One would like to think that the HTTP -# specification rules this out, but no bets. - class http_client(http_stream): parse_type = http_response @@ -454,27 +444,24 @@ class http_queue(object): return self.queue[0] else: self.log("Queue not empty but connection not usable, spawning") - self.client = http_client(self, hostport) + self.client = http_client(self, self.hostport) self.log("Spawned connection %r" % self.client) return None -class http_manager(object): +class http_manager(dict): log = logger - def __init__(self): - self.queues = {} - def query(self, url, callback, body = None): 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, callback = callback, Host = u.hostname, Content_Type = "text/plain") hostport = (u.hostname or "localhost", u.port or 80) - if hostport in self.queues: - self.queues[hostport].request(request) + if hostport in self: + self[hostport].request(request) else: - self.queues[hostport] = http_queue(hostport, request) + self[hostport] = http_queue(hostport, request) # server: reuse rest-style dispatcher from current https code. # |