Opened 4 years ago

Closed 3 years ago

#12522 closed Bug (duplicate)

Unable to get request.POST after request.get_raw_post_data

Reported by: redbaron 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:


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 redbaron 4 years ago.
Fix patch + regression tests on WSGI handler
12522-tests.diff (2.9 KB) - added by ramiro 3 years ago.
Tests converted to unit tests

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by redbaron

  • Component changed from Uncategorized to HTTP handling
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Changed 4 years ago by redbaron

Fix patch + regression tests on WSGI handler

comment:2 Changed 4 years ago by redbaron

  • 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 4 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 4 years ago by kmtracey

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

comment:5 Changed 4 years ago by zimnyx

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

comment:6 Changed 3 years ago by zimnyx

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

Changed 3 years ago by ramiro

Tests converted to unit tests

comment:7 Changed 3 years ago by ramiro

  • 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 3 years ago by mattmcc

  • Severity set to Normal
  • Type set to Bug

comment:9 Changed 3 years ago by vkryachko

  • Resolution set to duplicate
  • Status changed from new to closed

This is a duplicate of #15679

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.