在一个appengine项目中我试图在webapp2.RequestHandler中获取整个http请求:
class ConnectedHandler(webapp2.RequestHandler):
def post(self):
logging.info("Someone connected: " + self.request.get('from'))
# How to get the raw http request from self.request?
仔细阅读文档,我开始认为它不可能
我正在寻找的结果是这样的(无论如何我会称之为http请求):
POST /6473924464345088 HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate, compress
Content-Type: application/json; charset=utf-8
Host: localhost:10083
User-Agent: HTTPie/0.3.0
{
"u": "a"
}
修改:更新了示例
使用webapp2时是否有其他切割方法可以访问此数据?
答案 0 :(得分:2)
这应该可以帮到你:
class MainPage(webapp2.RequestHandler):
def post(self):
self.response.write('Just received:\n\n' + str(self.request))