-1

I'm coming across a rather strange problem in a small app I've made for Google App Engine. This is not intended to be accessed by a browser but to provide a kind of rudimentary REST API for another system. This is the basic structure of the app:

import webapp2

class MainPage(webapp2.RequestHandler):
    def post(self):
        <do good stuff>
    def get(self):
        raise Exception("Cannot call this app through a get request")

app = webapp2.WSGIApplication([('/objviewer/', MainPage)],debug=True)

It works fine with this in my app.yaml:

- url: /objviewer/
  script: gaeobjviewer.app

and with this code from a python script to call it:

encodedurl = urllib.urlencode({'tablename':tablename,'objid':objid})
# uploadservers[uploadkey] in the next line is a URL
response = urllib2.urlopen(uploadservers[uploadkey], data = encodedurl)
print response.read()

Now, in my app.yaml, suppose I add in a "secure: always" line:

- url: /objviewer/
  secure: always
  script: gaeobjviewer.app

The script promptly fails and claims it's being called with a get request. self.request.GET reports an empty dictionary.

Changing the protocol from http to https or vice versa in the urllib2.urlopen call makes no difference.

In the available literature on https I can find nothing about an empty GET request. Nor is there any reference to this in the GAE documentation that I can find. Why might this be occurring?

4

1 回答 1

0

事实证明,将调用 URL 设置为 https,然后删除最后的斜杠(如果有的话),将导致发送一个 post 请求。我不知道为什么会这样,但显然它与重定向有关,正如 Bryce Cutt 的评论中所指出的那样。

于 2013-10-18T11:42:47.173 回答