Message4041
The following example asyncore http client provided in the Python
Library Reference of Python2.5.4 documentation works in Python 2.5 but
not in Jython. Python 2.5 returns the text of the html page. Jython 2.5
returns nothing.
import asyncore, socket
class http_client(asyncore.dispatcher):
def __init__(self, host, path):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect( (host, 80) )
self.buffer = 'GET %s HTTP/1.0\r\n\r\n' % path
def handle_connect(self):
pass
def handle_close(self):
self.close()
def handle_read(self):
print self.recv(8192)
def writable(self):
return (len(self.buffer) > 0)
def handle_write(self):
sent = self.send(self.buffer)
self.buffer = self.buffer[sent:]
c = http_client('www.python.org', '/')
asyncore.loop() |
|
Date |
User |
Action |
Args |
2009-01-13 11:41:32 | mlevalle | set | recipients:
+ mlevalle |
2009-01-13 11:41:32 | mlevalle | set | messageid: <1231846892.19.0.837996923532.issue1237@psf.upfronthosting.co.za> |
2009-01-13 11:41:32 | mlevalle | link | issue1237 messages |
2009-01-13 11:41:31 | mlevalle | create | |
|