Pab*_*ruz 6 python django http
我想在Django 1.3中读取原始HTTP请求.
有一个简单的方法吗?
我尝试了以下但没有成功:
clength = int(request.META.get("CONTENT_LENGTH"))
data = request.read(1000)
# data comes out empty
Run Code Online (Sandbox Code Playgroud)
还尝试过:
for part in request:
pass
# never enters the loop
Run Code Online (Sandbox Code Playgroud)
我这样做的原因是因为在命令上raw_post_data使用multipart/relatedMIME信息时我的属性是空的POST.显然是一个已经存在了很长时间的bug.
您尝试过 HttpRequest.raw_post_data 吗?看起来你应该看看这个错误,直到错误得到修复。 https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.HttpRequest.raw_post_data