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

Delta Between Two Patch Sets: src/org/adblockplus/brazil/RequestHandler.java

Issue 29331923: Issue 3364 - Implement JNI bindings for IsDocument/ElemhideWhitelisted (Closed)
Left Patch Set: Created Dec. 4, 2015, 3:14 p.m.
Right Patch Set: Typo Created Dec. 4, 2015, 5:44 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/org/adblockplus/android/AndroidWebRequest.java ('k') | src/org/adblockplus/libadblockplus/FilterEngine.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 referer = request.getRequestHeader("referer"); 119 final String referrer = request.getRequestHeader("referer");
120 try 120 try
121 { 121 {
122 block = application.matches(request.url, request.query, referer, request.g etRequestHeader("accept")); 122 block = application.matches(request.url, request.query, referrer, request. getRequestHeader("accept"));
123 } 123 }
124 catch (final Exception e) 124 catch (final Exception e)
125 { 125 {
126 Log.e(prefix, "Filter error", e); 126 Log.e(prefix, "Filter error", e);
127 } 127 }
128 128
129 request.log(Server.LOG_LOG, prefix, block + ": " + request.url); 129 request.log(Server.LOG_LOG, prefix, block + ": " + request.url);
130 130
131 int count = request.server.requestCount; 131 int count = request.server.requestCount;
132 if (shouldLogHeaders) 132 if (shouldLogHeaders)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 try 225 try
226 { 226 {
227 reqHost = (new URL(request.url)).getHost(); 227 reqHost = (new URL(request.url)).getHost();
228 } 228 }
229 catch (final MalformedURLException e) 229 catch (final MalformedURLException e)
230 { 230 {
231 // 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.
232 } 232 }
233 233
234 selectors = application.getSelectorsForDomain(reqHost, referer); 234 selectors = application.getSelectorsForDomain(reqHost, referrer);
235 } 235 }
236 // If no filters are applicable just pass through the response 236 // If no filters are applicable just pass through the response
237 if (selectors == null || target.getResponseCode() != 200) 237 if (selectors == null || target.getResponseCode() != 200)
238 { 238 {
239 final int contentLength = target.getContentLength(); 239 final int contentLength = target.getContentLength();
240 if (contentLength == 0) 240 if (contentLength == 0)
241 { 241 {
242 // we do not use request.sendResponse to avoid arbitrary 242 // we do not use request.sendResponse to avoid arbitrary
243 // 200 -> 204 response code conversion 243 // 200 -> 204 response code conversion
244 request.sendHeaders(-1, null, -1); 244 request.sendHeaders(-1, null, -1);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 request.sendError(500, msg); 403 request.sendError(500, msg);
404 Log.e(prefix, msg, e); 404 Log.e(prefix, msg, e);
405 } 405 }
406 finally 406 finally
407 { 407 {
408 target.close(); 408 target.close();
409 } 409 }
410 return true; 410 return true;
411 } 411 }
412 } 412 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld