HTTP application streams a response to the client gradually - how deal with it?

Alan Kennedy alanmk at
Wed Apr 30 11:20:47 CEST 2003


> There is a existing Chat server, using HTTP / HTML. Currently it only
> works with Internet-Explorer as a client. Lynx is unlucky, Mozilla works
> only half.
> So I want to do a Chat Client in Python.

Ah, I see better now what you're trying to do.

Is the following the reason why you cannot use urllib and httplib:
because they block your client from doing anything but connecting to the
server? I.E. You want to be able to read the user input channel at the
same time as retrieving updates from the server. And because urllib and
httplib encapsulate the entire request/response inside one method call,
your client is blocked while the server call is executing, and thus very

There is a simple solution to that problem: use multiple threads. One
thread reads input from the user, another thread does nothing but
contact the server periodically for updates.

If the latter is the case, post again, and I'll post sample code or
links to same.

> Perhaps translating from the
> HTTP-Stream to another protocol.
> So your feedback was valuable - especially the part about Request /
> Response. It looks as if I have to go the socket way. Maybe a second try
> with twisted.

Given what you've said, I'd say it's probably overkill to go down to the
socket level. If you do that, then you'll find yourself both creating
and parsing HTTP messages, in order to interact with the HTTP server,
which is a non-trivial exercise. Urllib and httplib have all the
functionality you need, and (mostly) bug free, having been used by
thousands of people over the years. Rolling your own HTTP protocol would
be an enormous amount of work, due to the wide range of weird and
wonderful ways in which HTTP is used and abused.


alan kennedy
check http headers here:
email alan:    

More information about the Python-list mailing list