#14035: Cannot access POST after request.encoding was set to a custom value
-------------------------------+-----------------------------------------
     Reporter:  Piotr Czachur  |                    Owner:  Piotr Czachur
         Type:  Bug            |                   Status:  assigned
    Component:  HTTP handling  |                  Version:  dev
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+-----------------------------------------

Comment (by Stephane Poss):

 Hello,
 5 years later and 3h of debugging... I stumbled on this. There was a
 discrepancy between my production code and my unittests: works in prod,
 not in test. My code listens to Paypal IPNs, they do not necessarily
 encode their payload in utf-8, it's given in a field of the POST data.
 They do not document the content-type used. The unittests use multipart
 /form-data.
 Using https://docs.djangoproject.com/en/3.2/ref/unicode/#form-submission
 lead me to believe I could change the encoding after reading the POST data
 -> cannot work in unittest without changing the content type (all good
 once the actual content type to use is 'guessed'). I believe a note must
 be added to https://docs.djangoproject.com/en/3.2/ref/unicode/#form-
 submission explaining that changing the encoding based on POST data
 content **only** works if the content-type is application/x-www-form-
 urlencoded.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/14035#comment:20>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.9144fb86e27410b0d8f80c1b4d45a1f1%40djangoproject.com.

Reply via email to