6

How can I get the raw data from a POST request in Flask?

I am moving from web.py to Flask and have some clients in production that unfortunately are using the content-type header application/x-www-form-urlencoded, so changing the header value of the request is not an option (unless it is overwritten on the server).

I cannot use:

data = request.form.keys()[0]

Because occasionally the '&' character shows up in my data and trying to loop through the form.keys adding the '&' seems to corrupt the data for some reason.

I'm currently using the solution proposed in this post, but I'm not too sure if this has any performance issues.

I'm looking for one of three things:

  1. Confirmation that the WGSICopyBody method won't have any adverse performance issues
  2. Ability to make this (data = request.form.keys()[0]) method work by looping through the keys and properly restoring the '&' in the data
  3. Another solution to the problem, possibly by subclassing the Request class?
Community
  • 1
  • 1
Ashu Desai
  • 82
  • 1
  • 6

0 Answers0