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

Unified Diff: libadblockplus-android/jni/JniWebRequest.cpp

Issue 29345369: Issue 4081 - Fix failing MockWebRequestTest test for libadblockplus-android (Closed)
Patch Set: reverting changes to .hgignore Created Sept. 13, 2016, 10:34 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 | « .hgignore ('k') | libadblockplus-android/jni/Utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android/jni/JniWebRequest.cpp
diff --git a/libadblockplus-android/jni/JniWebRequest.cpp b/libadblockplus-android/jni/JniWebRequest.cpp
index 3245a1a7e4fad77cd29b2e618bca2c73afc2939e..5d46b8f60fd754ee433ad703c856aaa68f12fc2f 100644
--- a/libadblockplus-android/jni/JniWebRequest.cpp
+++ b/libadblockplus-android/jni/JniWebRequest.cpp
@@ -16,6 +16,7 @@
*/
#include "JniCallbacks.h"
+#include "Utils.h"
static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jobject callbackObject)
{
@@ -77,7 +78,26 @@ AdblockPlus::ServerResponse JniWebRequest::GET(const std::string& url,
serverResponseClass->Get(), *response, "responseStatus");
sResponse.responseText = JniGetStringField(*env,
serverResponseClass->Get(), *response, "response");
- // TODO: transform Headers
+
+ // map headers
+ jobjectArray responseHeadersArray = JniGetStringArrayField(*env,
+ serverResponseClass->Get(), *response, "headers");
+
+ if (responseHeadersArray)
+ {
+ int itemsCount = env->GetArrayLength(responseHeadersArray) / 2;
+ for (int i = 0; i < itemsCount; i++)
+ {
+ jstring jKey = (jstring)env->GetObjectArrayElement(responseHeadersArray, i * 2);
+ std::string stdKey = JniJavaToStdString(*env, jKey);
+
+ jstring jValue = (jstring)env->GetObjectArrayElement(responseHeadersArray, i * 2 + 1);
+ std::string stdValue = JniJavaToStdString(*env, jValue);
+
+ std::pair<std::string,std::string> keyValue(stdKey, stdValue);
+ sResponse.responseHeaders.push_back(keyValue);
+ }
+ }
}
}
« no previous file with comments | « .hgignore ('k') | libadblockplus-android/jni/Utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld