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; |
+ } |
+ |
+} |