I need to iterate over all request header objects and print it in App Engine. I get error when trying to use for cycle. How to do that correctly?
class MainHandler(webapp.RequestHandler):
def get(self):
for e in self.request.headers:
self.request.headers(e + "<br />")
I get error: AttributeError: EnvironHeaders instance has no __call__ method
Error is in
self.request.headers(e + "<br />")line. You are trying to call therequest.headersmethod.I check the online help and found that
self.request.headersisdictlike object. You can check in https://developers.google.com/appengine/docs/python/gettingstarted/usingwebappTo iterate over the
headersyou can useself.request.headers.items()orself.request.headers.keys()