@Brandon
Yes, 503 would probably be better then 401.

@Joshua
No 429 doesn't work. I don't know if the allowed return values are documented, 
but here's the source:
http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/ext/webapp/_webapp25.py#345


On Aug 3, 2012, at 10:45 AM, Joshua Smith wrote:

> 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 <[email protected]> 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 <[email protected]> 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 [email protected].
>>>> To unsubscribe from this group, send email to 
>>>> [email protected].
>>>> 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 [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> 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 [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> 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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to