我有以下测试代码:
@csrf_exempt
def view_test(request):
if request.method=="POST":
if 'Var1' in request.POST :
return HttpResponse("Flip")
else:
return HttpResponse("Flop")
我想通过 GPRS 将数据传递到我的 django 服务器,我正在发送这个“HTTP 数据包”
POST /test_pkt/ HTTP/1.1 \r\n
Host: test.my_django_server.com \r\n
User-Agent: Mozilla/5.0 \r\n
Accept: text/plain; q=0.5, text/html \r\n
Accept-Encoding: deflate \r\n
Accept-Language: en-US \r\n
Connection: keep-alive \r\n
Referer: http://test.my_django_server.com/test_pkt/ \r\n
Content-Type: application/x-www-form-urlencoded \r\n
Content-Length: 11 \r\n
Var1=toggle\r\n
\r\n
作为回应,我得到
HTTP/1.1 200 OK
Date: Tue, 02 Oct 2012 13:11:23 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: gunicorn/0.14.6
c
flop
0
我知道我做错了什么,但我找不到。有人可以指出我正确的方向。