-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
With the recent fix for handling binary payloads, we've discovered a new issue that did not occur with version 3.0.6: if you try to send a payload with a content-type of application/json, and a specified content length > 8192 bytes, then the first 8192 bytes is not preserved.
We have created the following 2 additional test cases for TestFieldStorageModified.py that demonstrates this issue; the first test without an explicit content-length passes, but the second does not:
`
def testRequestJSONLargeWithoutContentLength(self):
value = 'a'*8200
import json
d = {'test':value}
payload = json.dumps(d)
fs = FieldStorage(
fp=BytesIO(payload.encode()),
environ={'REQUEST_METHOD': 'POST',
'CONTENT_TYPE': 'application/json'})
self.assertEqual(fs.headers, {
'content-type': 'application/json'})
self.assertEqual(fs.type, 'application/json')
self.assertEqual(fs.length, -1)
self.assertEqual(fs.bytes_read, 8212)
assert fs.file.read() == payload
def testRequestJSONLargeWithContentLength(self):
value = 'a'*8200
import json
d = {'test':value}
payload = json.dumps(d)
fs = FieldStorage(
fp=BytesIO(payload.encode()),
environ={'REQUEST_METHOD': 'POST',
'CONTENT_TYPE': 'application/json',
'CONTENT_LENGTH': len(payload)})
self.assertEqual(fs.headers, {
'content-type': 'application/json', 'content-length': 8212})
self.assertEqual(fs.type, 'application/json')
self.assertEqual(fs.length, 8212)
self.assertEqual(fs.bytes_read, 8212)
assert fs.file.read() == payload
`
It isn't clear to me yet how the recent changes caused this problem, but these both pass with 3.0.6.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels