You're trying to find curl requests by looking for a "win" string?
IIRC, curl uses "curl" as its default user-agent, you have to look for
that. Also, it's a bad idea to look for "Win", as legitimate requests
(users using WINdows) will be blocked.

Also, it should be noted (and I believe a number of people have
already mentioned) that curl allows a person to change their user-
agent; just looking for a "curl" user-agent may not stop the problem.

On Aug 2, 1:55 pm, Kate <[email protected]> wrote:
> Well I tried this by testing user agent but it passes the test and the page
> loads correctly, which it shouldn't in this example.
> Am I meant to pass 'app' as such? I am not sure of this parameter.
>
> Here is my code
> from webob import Response
>
> class AntiCurlMiddleware(object):
>     def __init__(self, app):
>         self.app = app
>
>     def __call__(self, environ, start_response):
>         ua = os.environ.get('HTTP_USER_AGENT', "unknown")
> sindex = string.find(ua,'Win',0)
> if sindex > 0:
>       resp = Response('Too many requests!')
>       resp.status_code = 423
>       return resp(environ, start_response)
>         return self.app(environ, start_response)
>
> def webapp_add_wsgi_middleware(app):
>     return AntiCurlMiddlewarey(app)
>
>
>
>
>
>
>
> On Wednesday, August 1, 2012 4:43:58 PM UTC-4, Kate wrote:
>
> > I am getting tens of thousands of curl requests - many thousands time
> > browser requests and I want to block them. I'm using python. They coming
> > from many different IPs most in Europe.  If I can't stop them I will have
> > to close my site or go to a new provider.
>
> > Thank in advance,
>
> > Kate

-- 
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