I would have thought self.error(429). That doesn't work? Is there a doc that says what codes are are allowed to return?
On Aug 3, 2012, at 11:02 AM, Kyle Finley <kylefin...@gmail.com> wrote: > Yes, thank you. Do you have any thoughts on how to return error code 429? > > On Aug 3, 2012, at 9:51 AM, Joshua Smith wrote: > >> There are couple problems with your snippet. >> >> First, she's getting HEAD not GET requests, so you need to use different >> handler. >> >> Also, you aren't returning, so if you were in a GET request, it would >> proceed to handle the request regardless. >> >> Something more like this (untested): >> >> class MainHandler(webapp.RequestHandler): >> def head(self): >> self.error(401) >> >> def get(self): >> if (self.request.headers['User-Agent'].startswith('curl')) >> self.error(401) >> return >> # rest of the get handler >> >> On Aug 3, 2012, at 10:34 AM, Kyle Finley <kylefin...@gmail.com> wrote: >> >>> Hi Joshua, >>> >>> Thank you, that's a good thought. >>> >>> Kate sent me some files offline, and I believe we've figured out the >>> problem. For the middleware to work you must be using WSGI not CGI. Someone >>> please correct me if I'm wrong, but I believe she would have to upgrade >>> here App to python27 to use it. The alternative is to do the check in the >>> webapp request handler: >>> >>> def check_for_curl(self): >>> if self.request.environ['HTTP_USER_AGENT'].startswith('curl'): >>> return self.error(401) >>> >>> class MainHandler(webapp.RequestHandler): >>> def get(self): >>> check_for_curl(self) >>> # handle request >>> >>> The problem is that webapp doesn't recognize error code 429 so we have to >>> use something else. Unless there's a simple way to make it write 429? >>> >>> - Kyle >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Google App Engine" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/google-appengine/-/TQuZYYR0wrAJ. >>> To post to this group, send email to google-appengine@googlegroups.com. >>> To unsubscribe from this group, send email to >>> google-appengine+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/google-appengine?hl=en. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine" group. >> To post to this group, send email to google-appengine@googlegroups.com. >> To unsubscribe from this group, send email to >> google-appengine+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/google-appengine?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to google-appengine@googlegroups.com. > To unsubscribe from this group, send email to > google-appengine+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.