加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

在Django 1.3中读取原始HTTP请求

发布时间:2020-12-16 22:14:11 所属栏目:Python 来源:网络整理
导读:我想在Django 1.3中读取原始HTTP请求. 有一个简单的方法吗? 我尝试了以下但没有成功: clength = int(request.META.get("CONTENT_LENGTH"))data = request.read(1000)# data comes out empty 还尝试过: for part in request: pass # never enters the loop

我想在Django 1.3中读取原始HTTP请求.

有一个简单的方法吗?

我尝试了以下但没有成功:

clength = int(request.META.get("CONTENT_LENGTH"))
data = request.read(1000)
# data comes out empty

还尝试过:

for part in request:
    pass
    # never enters the loop

我这样做的原因是因为在POST命令上使用多部分/相关MIME信息时,我的raw_post_data属性是空的.显然是bug that’s been there for a long time.

最佳答案
你试过HttpRequest.raw_post_data吗?在修复错误之前,您应该看一下这些内容.
https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.HttpRequest.raw_post_data

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读