Python: adjusted input.read(size) argument value interpretation.
Previously, passing 0 resulted in reading the whole body and all negative values raised an exception. Now the behaviour is in consistentance with io.RawIOBase.read() interface, and passing 0 returns empty (byte) string, while -1 results in reading the whole body.
This commit is contained in:
@@ -1136,11 +1136,13 @@ nxt_py_input_read(nxt_py_input_t *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (size != -1) {
|
||||
return PyErr_Format(PyExc_ValueError,
|
||||
"the read body size cannot be zero or less");
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0 || size > (Py_ssize_t) ctx->req->content_length) {
|
||||
if (size == -1 || size > (Py_ssize_t) ctx->req->content_length) {
|
||||
size = ctx->req->content_length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,6 @@ Connection: close
|
||||
|
||||
self.assertEqual(self.post(body=body)['body'], body, 'input iter')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_python_application_input_read_length(self):
|
||||
self.load('input_read_length')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user