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. 1, 2012, 9:46 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("://"))
Felix Dahlke 2012/11/08 20:00:43 Since we're only dealing with HTTP(S), something l
Andrey Novikov 2012/11/09 09:23:47 Why are we? It's universal, it rewrites: GET /file
+ {
+ request.url = "http://" + request.headers.get("host") + request.url;
+ }
+ return false;
+ }
+
+}

Powered by Google App Engine
This is Rietveld