Get full raw http request (complete with headers and body)

748 views Asked by At

In a appengine project im trying to get the whole http request inside an webapp2.RequestHandler:

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? 

Having looked through the documentation im begining to think its not possible

The result im looking for is something like this (What i would call a http request anyways):

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"
}

Edit: Updated the example

Is there another cleaver way to access this data when using webapp2 ?

1

There are 1 answers

0
Lukasvan3L On

This should get you exactly that:

class MainPage(webapp2.RequestHandler):
    def post(self):
        self.response.write('Just received:\n\n' + str(self.request))