[Inteproxy-commits] r367 - in trunk: . inteproxy
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Wed Jun 26 15:25:43 CEST 2013
Author: bh
Date: 2013-06-26 15:25:43 +0200 (Wed, 26 Jun 2013)
New Revision: 367
Modified:
trunk/ChangeLog
trunk/inteproxy/httpmessage.py
Log:
* inteproxy/httpmessage.py (HTTPResponseMessage.read): Omit the
amount parameter entirely when calling the underlying body
stream's read method in the case where the caller of
HTTPResponseMessage.read wants to read all the contents of the
body because there does not seem to be a value usable as the
amount parameter in this case that is understood by all the
file-like types we may encounter. See the comment for more
details.
Fixes geospatial/issue617
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2013-06-25 14:23:59 UTC (rev 366)
+++ trunk/ChangeLog 2013-06-26 13:25:43 UTC (rev 367)
@@ -1,3 +1,15 @@
+2013-06-26 Bernhard Herzog <bh at intevation.de>
+
+ * inteproxy/httpmessage.py (HTTPResponseMessage.read): Omit the
+ amount parameter entirely when calling the underlying body
+ stream's read method in the case where the caller of
+ HTTPResponseMessage.read wants to read all the contents of the
+ body because there does not seem to be a value usable as the
+ amount parameter in this case that is understood by all the
+ file-like types we may encounter. See the comment for more
+ details.
+ Fixes geospatial/issue617
+
2013-06-25 Bjoern Schilberg <bjoern.schilberg at intevation.de>
Bumped version to 1.2.0.
Modified: trunk/inteproxy/httpmessage.py
===================================================================
--- trunk/inteproxy/httpmessage.py 2013-06-25 14:23:59 UTC (rev 366)
+++ trunk/inteproxy/httpmessage.py 2013-06-26 13:25:43 UTC (rev 367)
@@ -229,4 +229,22 @@
" in HTTPResponse")
else:
self._body_stream = self.infile
- return self._body_stream.read(amount)
+
+ # Passing the amount value to the read method of the body stream
+ # is tricky for the case of an omitted amount value, i.e. one
+ # indicating that all the data should be read. The only thing
+ # the various implementations seem to have in common is that an
+ # omitted amount parameter indicates this. In all cases I have
+ # looked at it is possible to pass a value for this parameter
+ # with the same meaning, but the value used differs. Some
+ # examples:
+ #
+ # File-like type Value for omitted amount parameter
+ # file negative integer
+ # httplib.HTTPResponse None
+ # zlib.decompressobj 0
+ #
+ # Since we may be dealing with any of these and perhaps more,
+ # the only way to pass the amount parameter while retaining the
+ # correct semantics is to use a possibly empty parameter tuple.
+ return self._body_stream.read(*((amount,) if amount > 0 else ()))
More information about the Inteproxy-commits
mailing list