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

  • Home
  • SEARCH
  • 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 987901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:33:26+00:00 2026-05-16T05:33:26+00:00

I am writing a google app engine app and I have this key value

  • 0

I am writing a google app engine app and I have this key value error upon requests coming in

from the backtrace I just access and cause the key error

self.request.headers

entire code snippet is here, I just forward the headers unmodified

     response = fetch( "%s%s?%s" % (
                                        self.getApiServer() ,
                                        self.request.path.replace("/twitter/", ""),
                                        self.request.query_string
                                    ),
                        self.request.body,
                        method,
                        self.request.headers,
                    )

and get method handling the request calling proxy()

# handle http get   
def get(self, *args):
    parameters = self.convertParameters(self.request.query_string)
    # self.prepareHeader("GET", parameters)
    self.request.query_string = "&".join("%s=%s" % (quote(key) , quote(value)) for key, value in parameters.items())
    self.proxy(GET, *args)
def convertParameters(self, source):
    parameters = {}
    for pairs in source.split("&"):
        item = pairs.split("=")
        if len(item) == 2:
            parameters[item[0]] = unquote(item[1])
    return parameters

the error back trace:

'CONTENT_TYPE'
Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 513, in __call__
    handler.post(*groups)
  File "/base/data/home/apps/waytosing/1.342850593213842824/com/blogspot/zizon/twitter/RestApiProxy.py", line 67, in post
    self.proxy(POST, *args)
  File "/base/data/home/apps/waytosing/1.342850593213842824/com/blogspot/zizon/twitter/RestApiProxy.py", line 47, in proxy
    self.request.headers,
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/urlfetch.py", line 240, in fetch
    allow_truncated, follow_redirects)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/urlfetch.py", line 280, in make_fetch_call
    for key, value in headers.iteritems():
  File "/base/python_runtime/python_dist/lib/python2.5/UserDict.py", line 106, in iteritems
    yield (k, self[k])
  File "/base/python_runtime/python_lib/versions/1/webob/datastruct.py", line 40, in __getitem__
    return self.environ[self._trans_name(item)]
KeyError: 'CONTENT_TYPE'

Any idea why it happens or is this a known bug?

  • 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-05-16T05:33:26+00:00Added an answer on May 16, 2026 at 5:33 am

    This looks weird. The docs mention that response “Headers objects do not raise an error when you try to get or delete a key that isn’t in the wrapped header list. Getting a nonexistent header just returns None”. It’s not clear from the request documentation if request.headers are also objects of this class, but even they were regular dictionaries, iteritems seems to be misbehaving. So this might be a bug.

    It might be worth inspecting self.request.headers, before calling fetch, and see 1) its actual type, 2) its keys, and 3) if trying to get self.request.headers[‘CONTENT_TYPE’] raises an error then.

    But, if you simply want to solve your problem and move forward, you can try to bypass it like:

    if 'CONTENT_TYPE' not in self.request.headers:
        self.request.headers['CONTENT_TYPE'] = None
    

    (I’m suggesting setting it to None, because that’s what a response Header object should return on non-existing keys)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a query to fetch results for all the values in a
I am learning on my own about writing an interpreter for a programming language,

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.