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: Codestyle fixes #3 Created Sept. 8, 2016, 1:31 p.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
diff --git a/libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java b/libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java
index 6796cd076d45eb8da866a989f02d6362df3756aa..0b106be59ce6cc7d7dd4e97dfe0890e9091fc9e7 100644
--- a/libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java
+++ b/libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java
@@ -22,7 +22,9 @@ 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;
@@ -124,10 +126,26 @@ public class AndroidWebRequest extends WebRequest
}
}
- connection.disconnect();
-
response.setStatus(NsStatus.OK);
response.setResponse(sb.toString());
+
+ if (connection.getHeaderFields().size() > 0)
+ {
+ List<HeaderEntry> responseHeaders = new LinkedList<HeaderEntry>();
+ for (Map.Entry<String, List<String>> eachEntry : 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
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld