Author airadier
Recipients airadier
Date 2007-12-14.12:52:00
SpamBayes Score 0.114235
Marked as misclassified No
Message-id <1197636721.61.0.0455165758222.issue1627@psf.upfronthosting.co.za>
In-reply-to
Content
When opening an IP Webcam URL with urllib2, the response is a continuous
secuence of Jpeg files from the server, preceded by the following headers:

Server: DM-Web
Content-type:
multipart/x-mixed-replace;boundary=0plm(Pico-Web:Server-Push:Boundary-String)1qaz
Content-length: -1

As you can see, the Content-Type is multipart/x-mixed-replace, and the
Content-Length reported by the server is '-1', which is strange (I guess
it would be better not to report Content-Length)

The problem is trying to read anything from the file-like object
returned by urlopen will block forever. Problem seems to be here, in
httplib.py, class HTTPResponse, method 'begin':

...
        # will the connection close at the end of the response?
        self.will_close = self._check_close()

        # do we have a Content-Length?
        # NOTE: RFC 2616, S4.4, #3 says we ignore this if tr_enc is
"chunked"
        length = self.msg.getheader('content-length')
        if length and not self.chunked:
            try:
                self.length = int(length)
            except ValueError:
                self.length = None
        else:
            self.length = None
...

The length attribute is being set to '-1' which leads to blocking when
reading from the endless stream of data. (See the read method in class
_fileobject, socket.py).

I don't know if this is the right fix, but I would suggest changing:

        length = self.msg.getheader('content-length')
        if length and not self.chunked:

to:

        length = self.msg.getheader('content-length')
        if length >= 0 and not self.chunked:
History
Date User Action Args
2007-12-14 12:52:01airadiersetspambayes_score: 0.114235 -> 0.114235
recipients: + airadier
2007-12-14 12:52:01airadiersetspambayes_score: 0.114235 -> 0.114235
messageid: <1197636721.61.0.0455165758222.issue1627@psf.upfronthosting.co.za>
2007-12-14 12:52:01airadierlinkissue1627 messages
2007-12-14 12:52:00airadiercreate