What might be helpful would be:

1. Add some logging. Up top:

import logging

then in the __call__ method:

    def __call__(self, environ, start_response):
        logging.info('__call__ sees UA: "%s"', environ['HTTP_USER_AGENT'])
        if environ['HTTP_USER_AGENT'].startswith('curl'):

2. Deploy that

3. Check your logs. If you are being hit with lots of inbound curl calls, you 
should get some clues right away. But you can also try hitting it with curl 
yourself.



On Aug 2, 2012, at 8:39 PM, Kate <mss.ka...@gmail.com> wrote:

> I restarted the instance. I also got a copy of curl.exe for windows and it 
> lets me through! :-(
> 
> My code is exactly this (below) and is in the file appengine_config.py in the 
> root directory.
> 
> I also tested your example from my machine and got blocked.
> 
> I can't think of why this could be! I even altered appengine_config.py to 
> have a syntax error and it picked it up, so I know it is loading.
> 
> 
> from webob import Response
> 
> class AntiCurlMiddleware(object):
>     def __init__(self, app):
>         self.app = app
> 
>     def __call__(self, environ, start_response):
>         if environ['HTTP_USER_AGENT'].startswith('curl'):
>             resp = Response('Too many requests!')
>             resp.status = 423
>             return resp(environ, start_response)
>         return self.app(environ, start_response)
> 
> def webapp_add_wsgi_middleware(app):
>     return AntiCurlMiddleware(app)
> 
> 
> On Thursday, August 2, 2012 6:55:37 PM UTC-4, Kyle Finley wrote:
>> How do I restart the instance?
> at appengine.google.com in the instance section you should see a list of 
> instance. They each have a "Shutdown" button
> 
>> Yes it is in the root directory. I am stumped! I didn't think it was working 
>> as I tried testing for different browsers and it didn't catch them.
> 
> I don't know, that's strange. I'ts working here:
> http://anticurl.scotch-media.appspot.com/
> 
> And if you have included the file in your project, it should at the very 
> least stop me from using curl to access your site.
> 
> -- 
> 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/-/1jEROOXORQMJ.
> 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.

Reply via email to