Issue 7445: urllib2 (and urllib) should raise error for incomplete response (original) (raw)

This question is motivated by a question on Stack Overflow: http://stackoverflow.com/questions/1824069/urllib2-not-retrieving-entire-http-response

In the event the user receives an incomplete response when using urllib2 (and urllib), the library should raise an error to indicate the response is incomplete. This is a matter of checking if the Content-Length defined in the header matches the size of the retrieved response. While this can be done by the user, an exception will help alert the more unwitting, such as myself, by failing early.

urllib and urllib2, by definition, returns a file-like object which provides a variety of facilities, most common one being a reading the object to get the content.

What you are asking for is, to read the content, verify if it matches the Content-Length header, and raise an exception, if the there is a mis-match. This facility may not be good idea to implement in library, while it can be (and should be) taken care by the client which is using the obj.

I am -1 on this request and would like to close this as 'wont-fix'.