Python:BaseHTTPRequestHandler-阅读原始帖子 [英] Python: BaseHTTPRequestHandler - Read raw post
问题描述
我如何阅读STRING上的原始http帖子.我已经找到了几种阅读文章的解析版本的解决方案,但是我正在处理的项目提交了没有头的原始xml有效负载.因此,我试图找到一种方法来读取发布数据,而不将其解析为键=>值数组.
How do I read the raw http post STRING. I've found several solutions for reading a parsed version of the post, however the project I'm working on submits a raw xml payload without a header. So I am trying to find a way to read the post data without it being parsed into a key => value array.
推荐答案
我认为self.rfile.read(self.headers.getheader('content-length'))
应该将原始数据作为字符串返回.
根据直接在BaseHTTPRequestHandler类内部的文档:
I think self.rfile.read(self.headers.getheader('content-length'))
should return the raw data as a string.
According to the docs directly inside the BaseHTTPRequestHandler class:
- rfile is a file object open for reading positioned at the
start of the optional input data part;
这篇关于Python:BaseHTTPRequestHandler-阅读原始帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!