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

Unified Diff: libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java

Issue 29346561: Issue 4160 - Return headers in AndroidWebRequest (Closed)
Patch Set: Created June 16, 2016, 11:04 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java
===================================================================
--- a/libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java
+++ b/libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java
@@ -17,17 +17,19 @@
package org.adblockplus.android;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import org.adblockplus.libadblockplus.AdblockPlusException;
import org.adblockplus.libadblockplus.FilterEngine;
import org.adblockplus.libadblockplus.HeaderEntry;
import org.adblockplus.libadblockplus.ServerResponse;
import org.adblockplus.libadblockplus.ServerResponse.NsStatus;
import org.adblockplus.libadblockplus.WebRequest;
@@ -119,20 +121,31 @@
int character;
while ((character = reader.read()) != -1)
{
sb.append((char) character);
}
}
- connection.disconnect();
-
response.setStatus(NsStatus.OK);
response.setResponse(sb.toString());
+
+ // headers
René Jeschke 2016/07/12 16:05:09 This comment can be removed.
anton 2016/07/13 06:31:19 Acknowledged.
+ 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.
+ List<HeaderEntry> responseHeaders = new LinkedList<HeaderEntry>();
+ 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.
+ connection.getHeaderFields().entrySet())
+ for (String eachValue : eachEntry.getValue())
+ if (eachEntry.getKey() != null && eachValue != null)
+ responseHeaders.add(new HeaderEntry(eachEntry.getKey(), eachValue));
+ response.setReponseHeaders(responseHeaders);
+ }
+
+ connection.disconnect();
}
else
{
response.setStatus(NsStatus.ERROR_FAILURE);
}
return response;
}
catch (final Throwable t)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld