Message4041

Author mlevalle
Recipients mlevalle
Date 2009-01-13.11:41:31
SpamBayes Score 0.0004226874
Marked as misclassified No
Message-id <1231846892.19.0.837996923532.issue1237@psf.upfronthosting.co.za>
In-reply-to
Content
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()
History
Date User Action Args
2009-01-13 11:41:32mlevallesetrecipients: + mlevalle
2009-01-13 11:41:32mlevallesetmessageid: <1231846892.19.0.837996923532.issue1237@psf.upfronthosting.co.za>
2009-01-13 11:41:32mlevallelinkissue1237 messages
2009-01-13 11:41:31mlevallecreate