Trivial view sometimes fails in Chrome

17 views
Skip to first unread message

Pigletto

unread,
Oct 11, 2011, 6:07:40 AM10/11/11
to django...@googlegroups.com
Simple view, shown below, sometimes fail in Chrome browser (request is shown as Pending or doesn't return any content):

def exposer(request):
    return HttpResponse('Response from AJAX exposer')

That is called by AJAX, eg:
$.post('{% url exposer %}', {'bb':'aa'}, callback);

Suprisingly if I change my view to:

def exposer(request):
    request.POST  # yes, just call it
    return HttpResponse('Response from AJAX exposer')

it works properly. 

Also, If I don't send any data with my POST request it works:
$.post('{% url exposer %}', {}, callback);

Problem exists only in Chrome browser and in WSGI environment (I've checked with uWSGI and Cherokee, Django 1.3 and trunk).

Example application that exposes the problem:

Live version of this application at: 
http://chrometest.natcam.pl (clicking first button sometimes fails in Chrome).

Application might be installed with:
python bootstrap.py --distribute
bin/buildout
bin/django syncdb

Above will install uwsgi at bin/uwsgi, and uWSGI can be run with:

 bin/uwsgi -b 8192  -s 127.0.0.1:1088 -p 1 -z 15 -l 128 --wsgi-file bin/django.wsgi


Any ideas what happens? Why does use of request.POST change behaviour?

Kurtis

unread,
Oct 11, 2011, 12:05:44 PM10/11/11
to Django users
Honestly I don't have any experience with Django and AJAX Yet. Just in
case you haven't checked it out yet -- I've read you've got to submit
the CSRF with your calls though. Not sure if that helps at all. Good
luck!

On Oct 11, 6:07 am, Pigletto <pigle...@gmail.com> wrote:
> Simple view, shown below, sometimes fail in Chrome browser (request is shown
> as Pending or doesn't return any content):
>
> def exposer(request):
>     return HttpResponse('Response from AJAX exposer')
>
> That is called by AJAX, eg:
> $.post('{% url exposer %}', {'bb':'aa'}, callback);
>
> Suprisingly if I change my view to:
>
> def exposer(request):
>     request.POST  # yes, just call it
>     return HttpResponse('Response from AJAX exposer')
>
> it works properly.
>
> Also, If I don't send any data with my POST request it works:
> $.post('{% url exposer %}', {}, callback);
>
> Problem exists only in Chrome browser and in WSGI environment (I've checked
> with uWSGI and Cherokee, Django 1.3 and trunk).
>
> Example application that exposes the problem:https://bitbucket.org/pigletto/chrometest/src
>
> Live version of this application at:http://chrometest.natcam.pl(clicking first button sometimes fails in

Pigletto

unread,
Oct 11, 2011, 12:39:02 PM10/11/11
to django...@googlegroups.com
Honestly I don't have any experience with Django and AJAX Yet. Just in
case you haven't checked it out yet -- I've read you've got to submit
the CSRF with your calls though. Not sure if that helps at all. Good
luck! 
Thanks for the tip but I've switched CSRF off. 

I've just noticed that switching off 'keep-alive' at Cherokee solves this problem, so issue might be related to Cherokee... though I'm not sure - why it works after placing call to request.POST in my view? 

Javier Guerra Giraldez

unread,
Oct 11, 2011, 1:25:39 PM10/11/11
to django...@googlegroups.com
On Tue, Oct 11, 2011 at 11:39 AM, Pigletto <pigl...@gmail.com> wrote:
> I've just noticed that switching off 'keep-alive' at Cherokee solves this
> problem, so issue might be related to Cherokee... though I'm not sure - why
> it works after placing call to request.POST in my view?

sounds like Cherokee needs that the app reads the content. sounds
like a bug, or at least non-conforming. don't remember what the RFC
says, but i'd take it to the Cherokee devs.

--
Javier

Reply all
Reply to author
Forward
0 new messages