Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/brazil/RequestHandler.java

Issue 4705284891082752: Proxy configurators (Closed)
Patch Set: Update 1 Created Aug. 19, 2014, 10:43 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/org/adblockplus/brazil/RequestHandler.java
diff --git a/src/org/adblockplus/brazil/RequestHandler.java b/src/org/adblockplus/brazil/RequestHandler.java
index 3756e75aceb1a66e4fd949a610b08074d615e89e..303f9906fbea6bf446504b93307ffeaaeafcca31 100644
--- a/src/org/adblockplus/brazil/RequestHandler.java
+++ b/src/org/adblockplus/brazil/RequestHandler.java
@@ -29,6 +29,7 @@ import java.net.URL;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
@@ -86,6 +87,19 @@ public class RequestHandler extends BaseRequestHandler
private String via;
private static final Pattern RE_HTTP = Pattern.compile("^https?:");
+ private static final AtomicLong BLOCKED_REQUESTS = new AtomicLong();
+ private static final AtomicLong UNBLOCKED_REQUESTS = new AtomicLong();
+
+ public static long getBlockedRequestCount()
+ {
+ return BLOCKED_REQUESTS.get();
+ }
+
+ public static long getUnblockedRequestCount()
+ {
+ return UNBLOCKED_REQUESTS.get();
+ }
+
@Override
public boolean init(final Server server, final String prefix)
{
@@ -116,15 +130,19 @@ public class RequestHandler extends BaseRequestHandler
int count = request.server.requestCount;
if (shouldLogHeaders)
{
+ // FIXME Don't log to "err"
System.err.println(dumpHeaders(count, request, request.headers, true));
}
if (block)
{
request.sendHeaders(204, null, 0);
+ BLOCKED_REQUESTS.incrementAndGet();
return true;
}
+ UNBLOCKED_REQUESTS.incrementAndGet();
+
// Do not further process non-http requests
if (!RE_HTTP.matcher(request.url).find())
{

Powered by Google App Engine
This is Rietveld