mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-04 04:49:12 +00:00
minor cleanups
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1421 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
9b292b0567
commit
51541f7109
@ -664,6 +664,12 @@ public class DoSFilter implements Filter
|
|||||||
else
|
else
|
||||||
_rateTrackers.remove(_id);
|
_rateTrackers.remove(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "RateTracker/"+_id+"/"+_type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FixedRateTracker extends RateTracker
|
class FixedRateTracker extends RateTracker
|
||||||
@ -673,6 +679,7 @@ public class DoSFilter implements Filter
|
|||||||
super(id,type,numRecentRequestsTracked);
|
super(id,type,numRecentRequestsTracked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isRateExceeded(long now)
|
public boolean isRateExceeded(long now)
|
||||||
{
|
{
|
||||||
// rate limit is never exceeded, but we keep track of the request timestamps
|
// rate limit is never exceeded, but we keep track of the request timestamps
|
||||||
@ -685,6 +692,12 @@ public class DoSFilter implements Filter
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Fixed"+super.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -261,7 +261,12 @@ public class DoSFilterTest extends TestCase
|
|||||||
String request1="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nCookie: " + sessionId1 + "\r\n\r\n";
|
String request1="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nCookie: " + sessionId1 + "\r\n\r\n";
|
||||||
String request2="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nCookie: " + sessionId2 + "\r\n\r\n";
|
String request2="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nCookie: " + sessionId2 + "\r\n\r\n";
|
||||||
String last="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\nCookie: " + sessionId2 + "\r\n\r\n";
|
String last="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\nCookie: " + sessionId2 + "\r\n\r\n";
|
||||||
String responses = doRequests(request1+request2+request1+request2+request1,2,1100,1100,last);
|
|
||||||
|
// ensure the sessions are new
|
||||||
|
String responses = doRequests(request1+request2,1,1100,1100,last);
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
responses = doRequests(request1+request2+request1+request2+request1,2,1100,1100,last);
|
||||||
|
|
||||||
assertEquals(11,count(responses,"HTTP/1.1 200 OK"));
|
assertEquals(11,count(responses,"HTTP/1.1 200 OK"));
|
||||||
assertEquals(0,count(responses,"DoSFilter: delayed"));
|
assertEquals(0,count(responses,"DoSFilter: delayed"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user