| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the Adblock Plus, | 2 * This file is part of the Adblock Plus, |
| 3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 request.responseHeaders.add("Via", via); | 207 request.responseHeaders.add("Via", via); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // Detect if we need to add ElemHide filters | 210 // Detect if we need to add ElemHide filters |
| 211 String type = request.responseHeaders.get("Content-Type"); | 211 String type = request.responseHeaders.get("Content-Type"); |
| 212 | 212 |
| 213 String selectors = null; | 213 String selectors = null; |
| 214 if (type != null && type.toLowerCase().startsWith("text/html")) | 214 if (type != null && type.toLowerCase().startsWith("text/html")) |
| 215 { | 215 { |
| 216 selectors = application.getSelectorsForDomain(reqHost); | 216 selectors = application.getSelectorsForDomain(reqHost); |
| 217 if (selectors != null) | |
| 218 selectors = selectors.replace(",", ",\r\n"); | |
| 219 } | 217 } |
| 220 // If no filters are applicable just pass through the response | 218 // If no filters are applicable just pass through the response |
| 221 if (selectors == null || target.getResponseCode() != 200) | 219 if (selectors == null || target.getResponseCode() != 200) |
| 222 { | 220 { |
| 223 int contentLength = target.getContentLength(); | 221 int contentLength = target.getContentLength(); |
| 224 if (contentLength == 0) | 222 if (contentLength == 0) |
| 225 { | 223 { |
| 226 // we do not use request.sendResponse to avoid arbitrary | 224 // we do not use request.sendResponse to avoid arbitrary |
| 227 // 200 -> 204 response code conversion | 225 // 200 -> 204 response code conversion |
| 228 request.sendHeaders(-1, null, -1); | 226 request.sendHeaders(-1, null, -1); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 request.sendError(500, msg); | 366 request.sendError(500, msg); |
| 369 Log.e(prefix, msg, e); | 367 Log.e(prefix, msg, e); |
| 370 } | 368 } |
| 371 finally | 369 finally |
| 372 { | 370 { |
| 373 target.close(); | 371 target.close(); |
| 374 } | 372 } |
| 375 return true; | 373 return true; |
| 376 } | 374 } |
| 377 } | 375 } |
| OLD | NEW |