Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9120139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:33:41+00:00 2026-06-17T05:33:41+00:00

I was wondering how I would go about checking HTTP headers to determine whether

  • 0

I was wondering how I would go about checking HTTP headers to determine whether the request is valid or malformed. How can I do this in Python, more specifically, how can I do this in GAE?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:33:42+00:00Added an answer on June 17, 2026 at 5:33 am

    For some debugging and viewing the request with the headers I use the following DDTHandler class.

    import cgi
    import wsgiref.handlers
    import webapp2
    
    class DDTHandler(webapp2.RequestHandler):
    
        def __start_display(self):
            self.response.out.write("<!--\n")
    
        def __end_display(self):
            self.response.out.write("-->\n")
    
        def __show_dictionary_items(self,dictionary,title):
            if (len(dictionary) > 0):
                request = self.request
                out = self.response.out
                out.write("\n" + title + ":\n")
                for key, value in dictionary.iteritems():
                    out.write(key + " = " + value + "\n")
    
        def __show_request_members(self):
            request = self.request
            out = self.response.out
            out.write(request.url+"\n")
            out.write("Query = "+request.query_string+"\n")
            out.write("Remote = "+request.remote_addr+"\n")
            out.write("Path = "+request.path+"\n\n")
            out.write("Request payload:\n")
            if (len(request.arguments()) > 0): 
                for argument in request.arguments():
                    value = cgi.escape(request.get(argument))
                    out.write(argument+" = "+value+"\n")
            else:
                out.write("Empty\n")
    
            self.__show_dictionary_items(request.headers, "Headers")
            self.__show_dictionary_items(request.cookies, "Cookies")
    
        def view_request(self):
            self.__start_display()
            self.__show_request_members()
            self.__end_display()
    
        def view(self, aString):
            self.__start_display()
            self.response.out.write(aString+"\n")
            self.__end_display()
    

    Example:

    class RootPage(DDTHandler):
    
        def get(self):      
            self.view_request()
    

    Will output the request and contains the headers.

    So check the code and get what you need. Thought as said, a malformed “invalid” request won’t probably hit your app.

    <!--
    http://localhost:8081/
    Query = 
    Remote = 127.0.0.1
    Path = /
    
    Request payload:
    Empty
    
    Headers:
    Referer = http://localhost:8081/_ah/login?continue=http%3A//localhost%3A8081/
    Accept-Charset = ISO-8859-7,utf-8;q=0.7,*;q=0.3
    Cookie = hl=en_US; dev_appserver_login="test@example.com:False:185804764220139124118"
    User-Agent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
    Host = localhost:8081
    Accept = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language = en-US,en;q=0.8,el;q=0.6
    
    Cookies:
    dev_appserver_login = test@example.com:False:185804764220139124118
    hl = en_US
    -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering how would I go about checking to see if, for
I was wondering how I would go about checking to see if a table
I've been wondering about this: would you support using simply an object as a
I was wondering how one would go about developing a website from scratch with
I'm wondering how i would go about making the following application: a user signs
I am wondering how I would go about performing a certain function if a
I was wondering how I would go about mapping 2D screen coordinates to a
I'm wondering how I would go about the addition and subtraction of numbers in
I am fairly new to php and was wondering how I would go about
I was wondering how would go about displaying five images in a row using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.