/soc/2012/sanket/www-statscollector: 9dda7f362c2b: Return 400 --...
sanket
sanket at soc.pidgin.im
Tue Jul 10 01:30:20 EDT 2012
Changeset: 9dda7f362c2bb4412862649eacb4c627a82cae58
Author: sanket <sanket at soc.pidgin.im>
Date: 2012-07-08 02:39 +0530
Branch: default
URL: http://hg.pidgin.im/soc/2012/sanket/www-statscollector/rev/9dda7f362c2b
Description:
Return 400 -- bad request when POST request is broken
We should return proper HTTP error code to client when the request
is broken. This is useful in identifying that the client should
take appropriate action towards the error. Currently I have added
support for a ``400'' error response code.
diffstat:
pidgin_stats_collector/statscollector/views.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (28 lines):
diff --git a/pidgin_stats_collector/statscollector/views.py b/pidgin_stats_collector/statscollector/views.py
--- a/pidgin_stats_collector/statscollector/views.py
+++ b/pidgin_stats_collector/statscollector/views.py
@@ -1,5 +1,5 @@
# Create your views here.
-from django.http import HttpResponse
+from django.http import HttpResponse, HttpResponseBadRequest
from statscollector.models import *
from django.core.context_processors import csrf
from django.shortcuts import render_to_response
@@ -26,7 +26,7 @@
# Get the XML file as raw_post_data
stats_xml = request.POST['xml']
except:
- return HttpResponse('Broken POST request :=(\n')
+ return HttpResponseBadRequest('Broken POST request :=(\n')
# Parse the XML file
try:
@@ -53,7 +53,7 @@
# Return error if file cannot be parsed
except ExpatError:
- return HttpResponse('Broken POST XML file :=(\n')
+ return HttpResponseBadRequest('Broken POST XML file :=(\n')
@csrf_exempt
def collect(request):
More information about the Commits
mailing list