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

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

Issue 8484110: ABP/Android proxy service (Closed)
Patch Set: ABP/Android proxy service Created Nov. 9, 2012, 9:23 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/TransparentProxyHandler.java
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/org/adblockplus/brazil/TransparentProxyHandler.java
@@ -0,0 +1,32 @@
+package org.adblockplus.brazil;
+
+import java.io.IOException;
+
+import sunlabs.brazil.server.Handler;
+import sunlabs.brazil.server.Request;
+import sunlabs.brazil.server.Server;
+
+/**
+ * Reconstructs request url to comply with proxy specification if transparent
+ * proxy is used.
+ */
+public class TransparentProxyHandler implements Handler
+{
+
+ @Override
+ public boolean init(Server server, String prefix)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean respond(Request request) throws IOException
+ {
+ if (!request.url.contains("://"))
+ {
+ request.url = "http://" + request.headers.get("host") + request.url;
+ }
+ return false;
+ }
+
+}

Powered by Google App Engine
This is Rietveld