Problem with socket.recv()
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Thu May 17 06:35:43 EDT 2007
xreload wrote:
> Hello !
>
> So, lets do :
> sock.py "http://forums.childrenwithdiabetes.com/showthread.php?t=5030"
> - it not ok , only some part of document.
> wget "http://forums.childrenwithdiabetes.com/showthread.php?t=5030" -
> it ok !
> sock.py "http://www.google.com/" - it ok !
>
> Why i got only some part of document ? This is some bug in sockets
> module or i do something wrong in my code?
You have a bug in your code:
> def get_body(self):
> body = self.response.split("\r\n\r\n", 2)
> try:
> return body[1]
> except:
> return self.response
The split is breaking up the response in 2 splits, that is, three parts.
You meant to have it split up in TWO parts. So change the argument 2
to the split call, to 1.
Also, why not just use httplib/urllib etc? Just curious.
--Irmen
More information about the Python-list
mailing list