Left: | ||
Right: |
OLD | NEW |
---|---|
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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 package org.adblockplus.android; | 18 package org.adblockplus.android; |
19 | 19 |
20 import java.io.BufferedReader; | 20 import java.io.BufferedReader; |
21 import java.io.InputStreamReader; | 21 import java.io.InputStreamReader; |
22 import java.net.HttpURLConnection; | 22 import java.net.HttpURLConnection; |
23 import java.net.URL; | 23 import java.net.URL; |
24 import java.util.HashSet; | 24 import java.util.HashSet; |
25 import java.util.LinkedList; | |
25 import java.util.List; | 26 import java.util.List; |
27 import java.util.Map; | |
26 | 28 |
27 import org.adblockplus.libadblockplus.AdblockPlusException; | 29 import org.adblockplus.libadblockplus.AdblockPlusException; |
28 import org.adblockplus.libadblockplus.FilterEngine; | 30 import org.adblockplus.libadblockplus.FilterEngine; |
29 import org.adblockplus.libadblockplus.HeaderEntry; | 31 import org.adblockplus.libadblockplus.HeaderEntry; |
30 import org.adblockplus.libadblockplus.ServerResponse; | 32 import org.adblockplus.libadblockplus.ServerResponse; |
31 import org.adblockplus.libadblockplus.ServerResponse.NsStatus; | 33 import org.adblockplus.libadblockplus.ServerResponse.NsStatus; |
32 import org.adblockplus.libadblockplus.WebRequest; | 34 import org.adblockplus.libadblockplus.WebRequest; |
33 | 35 |
34 import android.util.Log; | 36 import android.util.Log; |
35 | 37 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 else | 119 else |
118 { | 120 { |
119 int character; | 121 int character; |
120 | 122 |
121 while ((character = reader.read()) != -1) | 123 while ((character = reader.read()) != -1) |
122 { | 124 { |
123 sb.append((char) character); | 125 sb.append((char) character); |
124 } | 126 } |
125 } | 127 } |
126 | 128 |
127 connection.disconnect(); | |
128 | |
129 response.setStatus(NsStatus.OK); | 129 response.setStatus(NsStatus.OK); |
130 response.setResponse(sb.toString()); | 130 response.setResponse(sb.toString()); |
131 | |
132 // headers | |
René Jeschke
2016/07/12 16:05:09
This comment can be removed.
anton
2016/07/13 06:31:19
Acknowledged.
| |
133 if (connection.getHeaderFields().size() > 0) { | |
René Jeschke
2016/07/12 16:05:09
Please pay attention to our coding style. Opening
anton
2016/07/13 06:31:19
Acknowledged.
| |
134 List<HeaderEntry> responseHeaders = new LinkedList<HeaderEntry>(); | |
135 for (Map.Entry<String, List<String>> eachEntry : | |
René Jeschke
2016/07/12 16:05:09
Please pay attention to indentation, this line (an
anton
2016/07/13 06:31:19
Acknowledged.
| |
136 connection.getHeaderFields().entrySet()) | |
137 for (String eachValue : eachEntry.getValue()) | |
138 if (eachEntry.getKey() != null && eachValue != null) | |
139 responseHeaders.add(new HeaderEntry(eachEntry.getKey(), eachVa lue)); | |
140 response.setReponseHeaders(responseHeaders); | |
141 } | |
142 | |
143 connection.disconnect(); | |
131 } | 144 } |
132 else | 145 else |
133 { | 146 { |
134 response.setStatus(NsStatus.ERROR_FAILURE); | 147 response.setStatus(NsStatus.ERROR_FAILURE); |
135 } | 148 } |
136 return response; | 149 return response; |
137 } | 150 } |
138 catch (final Throwable t) | 151 catch (final Throwable t) |
139 { | 152 { |
140 throw new AdblockPlusException("WebRequest failed", t); | 153 throw new AdblockPlusException("WebRequest failed", t); |
141 } | 154 } |
142 } | 155 } |
143 } | 156 } |
OLD | NEW |