Re: [Django] #30113: Ignoring body with application/json payload causes HTTP 400

2019-01-17 Thread Django
#30113: Ignoring body with application/json payload causes HTTP 400
--+--
 Reporter:  ymollard  |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  HTTP handling |  Version:  2.1
 Severity:  Normal|   Resolution:  duplicate
 Keywords:  post, body, json  | Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Please test with Django 2.1.15 as this looks like a duplicate of #30015.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.226f84fd238c0855440e19993b804f43%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30113: Ignoring body with application/json payload causes HTTP 400

2019-01-17 Thread Django
#30113: Ignoring body with application/json payload causes HTTP 400
--+--
 Reporter:  ymollard  |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  HTTP handling |  Version:  2.1
 Severity:  Normal|   Resolution:
 Keywords:  post, body, json  | Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Description changed by ymollard:

Old description:

> 1. Create an example view with Django 2.1.4 that does not consume the
> request's body:
> {{{
> @csrf_exempt
> def myview(request):
> #print(request.body.decode("utf8"))
> return HttpResponse()
> }}}
>
> 2. Now send a a first POST with **application/json** content type, e.g.
> with axios:
> {{{
> axios.post("/myview", {"some": "data"})
> }}}
>
> 3. Send new identical POST requests, and observe that they cause  HTTP
> 400 errors:
> {{{
> [17/Jan/2019 22:27:47] "POST /myview HTTP/1.1" 200 0
> [17/Jan/2019 22:27:48] "{"some":"data"}POST /myview HTTP/1.1" 200 0
> [17/Jan/2019 22:29:44] code 400, message Bad request syntax
> ('{"some":"data"}')
> [17/Jan/2019 22:29:44] "{"some":"data"}" 400 -
> }}}
> The JSON payload of the first request is still buffered somewhere and
> mess up later requests.
>
> 4. Now comment out the print function is the view, and see that consuming
> the payload has fixed the issue

New description:

 1. Create an example view with Django 2.1.4 that does not consume the
 request's body:
 {{{
 @csrf_exempt
 def myview(request):
 #print(request.body.decode("utf8"))
 return HttpResponse()
 }}}

 2. Now send a a first POST with **application/json** content type, e.g.
 with axios:
 {{{
 axios.post("/myview", {"some": "data"})
 }}}

 3. Send new identical POST requests, and observe that they cause  HTTP 400
 errors:
 {{{
 [17/Jan/2019 22:27:47] "POST /myview HTTP/1.1" 200 0
 [17/Jan/2019 22:27:48] "{"some":"data"}POST /myview HTTP/1.1" 200 0
 [17/Jan/2019 22:29:44] code 400, message Bad request syntax
 ('{"some":"data"}')
 [17/Jan/2019 22:29:44] "{"some":"data"}" 400 -
 }}}
 The JSON payload of the first request is still buffered somewhere and mess
 up later requests.

 4. Now comment out the print function in the view, and see that consuming
 the payload has fixed the issue

--

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.5fbed98312d13f0e9ecb9419e207785a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.