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

Side by Side Diff: src/org/adblockplus/brazil/RequestHandler.java

Issue 29331923: Issue 3364 - Implement JNI bindings for IsDocument/ElemhideWhitelisted (Closed)
Patch Set: Issues No. 1 Created Dec. 4, 2015, 3:55 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 via = " " + server.hostName + ":" + server.listen.getLocalPort() + " (" + se rver.name + ")"; 109 via = " " + server.hostName + ":" + server.listen.getLocalPort() + " (" + se rver.name + ")";
110 110
111 return true; 111 return true;
112 } 112 }
113 113
114 @Override 114 @Override
115 public boolean respond(final Request request) throws IOException 115 public boolean respond(final Request request) throws IOException
116 { 116 {
117 boolean block = false; 117 boolean block = false;
118 118
119 final String referrer = request.getRequestHeader("referer");
119 try 120 try
120 { 121 {
121 block = application.matches(request.url, request.query, request.getRequest Header("referer"), request.getRequestHeader("accept")); 122 block = application.matches(request.url, request.query, referrer, request. getRequestHeader("accept"));
122 } 123 }
123 catch (final Exception e) 124 catch (final Exception e)
124 { 125 {
125 Log.e(prefix, "Filter error", e); 126 Log.e(prefix, "Filter error", e);
126 } 127 }
127 128
128 request.log(Server.LOG_LOG, prefix, block + ": " + request.url); 129 request.log(Server.LOG_LOG, prefix, block + ": " + request.url);
129 130
130 int count = request.server.requestCount; 131 int count = request.server.requestCount;
131 if (shouldLogHeaders) 132 if (shouldLogHeaders)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 224
224 try 225 try
225 { 226 {
226 reqHost = (new URL(request.url)).getHost(); 227 reqHost = (new URL(request.url)).getHost();
227 } 228 }
228 catch (final MalformedURLException e) 229 catch (final MalformedURLException e)
229 { 230 {
230 // We are transparent, it's not our deal if it's malformed. 231 // We are transparent, it's not our deal if it's malformed.
231 } 232 }
232 233
233 selectors = application.getSelectorsForDomain(reqHost); 234 selectors = application.getSelectorsForDomain(reqHost, referrer);
234 } 235 }
235 // If no filters are applicable just pass through the response 236 // If no filters are applicable just pass through the response
236 if (selectors == null || target.getResponseCode() != 200) 237 if (selectors == null || target.getResponseCode() != 200)
237 { 238 {
238 final int contentLength = target.getContentLength(); 239 final int contentLength = target.getContentLength();
239 if (contentLength == 0) 240 if (contentLength == 0)
240 { 241 {
241 // we do not use request.sendResponse to avoid arbitrary 242 // we do not use request.sendResponse to avoid arbitrary
242 // 200 -> 204 response code conversion 243 // 200 -> 204 response code conversion
243 request.sendHeaders(-1, null, -1); 244 request.sendHeaders(-1, null, -1);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 request.sendError(500, msg); 403 request.sendError(500, msg);
403 Log.e(prefix, msg, e); 404 Log.e(prefix, msg, e);
404 } 405 }
405 finally 406 finally
406 { 407 {
407 target.close(); 408 target.close();
408 } 409 }
409 return true; 410 return true;
410 } 411 }
411 } 412 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/AndroidWebRequest.java ('k') | src/org/adblockplus/libadblockplus/FilterEngine.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld