class W(Worker): def run(self): #self.ah = AHTTP(self.sock, user=self) self.ah = AHTTP(self.sock) for y in self.ah.get_head(): yield y if self.ah.http_dict['headers'].getheader('content-length') > 0: for y in self.ah.get_body(): yield y #msg = self.ah.response_200("ididiid", {"Keep-Alive": "True"}) msg = self.ah.response_200("ididiid", {"Connection": "keep-alive"}) #msg = self.ah.build_http_msg("HTTP/1.1 200 OK", "ididiid") #, {"Keep-Alive": "True"}) for y in self.ah.write_all(msg): yield y print >> sys.stderr, "get one" for y in self.ah.get_head(): yield y if self.ah.http_dict['headers'].getheader('content-length') > 0: for y in self.ah.get_body(): yield y msg = self.ah.response_200("huhuu") for y in self.ah.write_all(msg): yield y self.sock.close()
class W(Acore): def run(self): print >>sys.stderr, "I am here" # self.ah = AHTTP(dest_addr=("127.0.0.1", 8080), user=self) self.ah = AHTTP(dest_addr=("172.17.94.72", 8080), user=self) msg = self.ah.build_get_request("/abcd") print >>sys.stderr, "I am here2" for y in self.ah.write_all(msg): yield y print >>sys.stderr, "I am here3" for y in self.ah.get_head(): yield y print >>sys.stderr, "I am here4" if self.ah.http_dict["headers"].getheader("content-length") > 0: for y in self.ah.get_body(): yield y print >>sys.stderr, "I am here5", self.ah.http_dict["body"].getvalue() # ------------------------- msg = self.ah.build_get_request("/abcd") for y in self.ah.write_all(msg): yield y print >>sys.stderr, "I am here6" for y in self.ah.get_head(): yield y print >>sys.stderr, "I am here7" if self.ah.http_dict["headers"].getheader("content-length") > 0: for y in self.ah.get_body(): yield y print >>sys.stderr, "I am here8", self.ah.http_dict["body"].getvalue()