Opened 7 years ago

Closed 5 years ago

#12522 closed Bug (duplicate)

Unable to get request.POST after request.get_raw_post_data

Reported by: Maxim Ivanov Owned by: nobody
Component: HTTP handling Version: 1.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

I need to get raw request body, the only solution I found is request.get_raw_post_data, but once I accessed it I am unable to use request.POST anymore. From my point of view access to request.POST should check if cached body data already exist and if yes try to use it instead of reading environwsgi.input?

Attachments (2)

raw_post.diff (3.4 KB) - added by Maxim Ivanov 7 years ago.
Fix patch + regression tests on WSGI handler
12522-tests.diff (2.9 KB) - added by Ramiro Morales 6 years ago.
Tests converted to unit tests

Download all attachments as: .zip

Change History (11)

comment:1 Changed 7 years ago by Maxim Ivanov

Component: UncategorizedHTTP handling
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Changed 7 years ago by Maxim Ivanov

Attachment: raw_post.diff added

Fix patch + regression tests on WSGI handler

comment:2 Changed 7 years ago by Maxim Ivanov

Has patch: set

Attaching patch which fixes problem for WSGI handler with regression tests provided. Patch for mod_python is there too. Basically it fixes access to request.POST and requst.raw_post_data in any order in case of multipart POST content type.

I am not familiar with mod_python and don't know what is 'req' argument passed by handler, thats why there are no regression tests for mod_python handler.

comment:3 Changed 7 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

comment:4 Changed 6 years ago by Karen Tracey

#14024 reported this again and proposed a different approach to fix.

comment:5 Changed 6 years ago by Piotr Czachur

This issue is related: #14035 (Cannot access POST after request.encoding was set to a custom value)

comment:6 Changed 6 years ago by Piotr Czachur

Another related issue: #14753 (Accessing (Get)HttpRequest.raw_post_data in view results in exception during testing)

Changed 6 years ago by Ramiro Morales

Attachment: 12522-tests.diff added

Tests converted to unit tests

comment:7 Changed 6 years ago by Ramiro Morales

Patch needs improvement: set

The patch doesn't apply anymore because a) Since then there has been a code shuffle for the HTTPRequest streaming feature and b) Most of our tests were converted to unit tests.

I've attached redbaron's tests updated to apply to trunk as of now. They add two failing cases.

comment:8 Changed 5 years ago by Matt McClanahan

Severity: Normal
Type: Bug

comment:9 Changed 5 years ago by vkryachko

Resolution: duplicate
Status: newclosed

This is a duplicate of #15679

Note: See TracTickets for help on using tickets.
Back to Top