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: Full changes set (including initial changeset for this issue and codestyle/commitstyle fixes) Created July 13, 2016, 6:52 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
Index: libadblockplus-android/jni/JniWebRequest.cpp
diff --git a/libadblockplus-android/jni/JniWebRequest.cpp b/libadblockplus-android/jni/JniWebRequest.cpp
index 3245a1a7e4fad77cd29b2e618bca2c73afc2939e..f2501fb632a7c63abe00a29f13671648ced21463 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++)
Felix Dahlke 2016/09/12 14:21:11 Nit: Spaces around operators (= and < here)?
+ {
+ 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);
+ }
+ }
}
}
« .hgignore ('K') | « .hgignore ('k') | libadblockplus-android/jni/Utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld