My Django view generates a PDF via pycairo in response to a POST (I'm not redirecting in response to the POST). When I POST using desktop browsers I can save and/or view the PDF using Adobe Reader or Document Viewer. However, when I POST via my android browsers the Adobe PDF Reader and the ThinkFree viewers both report the file as corrupted.
Looking in the logfiles on my appserver both Android browsers are sending a POST followed immediately by a GET for the same page:
[24/Sep/2010:22:49:20 -0500] "POST /courses/blank/create/ HTTP/1.1" 200 8895 "http://example.com/create/" "Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; SPH-D700 Build/ECLAIR) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"
[24/Sep/2010:22:49:20 -0500] "GET /courses/blank/create/ HTTP/1.1" 200 9432 "-" "Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; SPH-D700 Build/ECLAIR) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"
When I look at the file saved to the phone it is the HTML of the GET request.
Here's a skeleton of the view:
def create(request, template="blankgrids/create.html"):
if request.method == 'POST':
form = BlankGridForm(request.POST)
if form.is_valid():
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=example.pdf'
# snipped pycairo code that writes directly into response
return response
else:
form = BlankGridForm()
return render_to_response(template,
{'form': form},
context_instance=RequestContext(request))
So I'm wondering what could be causing the android browsers to perform the GET?