Use of httplib?

David Lees DavidL at
Wed Dec 13 22:04:22 CET 2000

I am running the client code below to try and send and receive text from
a server.  My problem is that I do not know how to recieve back an
arbitrary number of lines.  In a test case, when I know the exact number
of lines as shown below (e.g. 11) I can use readline.  However, in
general I do not know how many lines there are and the program hangs on
the connection when  I accidentaly read to the end.  The comment out
pieces of code also either hang or do not give back all the text.

I am copying from the Library Reference section 11.4, but it does not
seem to document the readline, read or readlines methods for http.

Thanks in advance for any help/pointers.

david lees

h = httplib.HTTP("")
h.putrequest('POST','/rpchandler HTTP/1.0')
h.putheader('Content-Type', 'text/xml')
h.putheader("Content-length", "%d" % len(bod))
reply, msg, hdrs = h.getreply()
print reply
print msg
print hdrs
f = h.getfile()
#print data

#print data

for i in range(11):
    print data

#while 1:
#   data=f.readline()
#    if not data:
#       break
#    print data


More information about the Python-list mailing list