I am looking for 'win' in user agent as that IS the USER Agent I am using to test. It should evaluate to true and give a 423 error.
I do not want to test it using curl. I am trying to see if I can return a 423 error. It is a TEST! I am running it locally to see if it will block. It doesn't. 'Win' is in my user agent - as I am testing. On Thursday, August 2, 2012 3:43:44 PM UTC-4, hyperflame wrote: > > 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 view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/_ihaQnsMLZ8J. 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.
