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: Created May 30, 2016, 2:56 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 | 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
===================================================================
--- a/libadblockplus-android/jni/JniWebRequest.cpp
+++ b/libadblockplus-android/jni/JniWebRequest.cpp
@@ -72,17 +72,40 @@
if (!env->ExceptionCheck())
{
sResponse.status = JniGetLongField(*env, serverResponseClass->Get(),
*response, "status");
sResponse.responseStatus = JniGetIntField(*env,
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++) {
+ // key
+ jstring jKey = (jstring)env->GetObjectArrayElement(responseHeadersArray, i * 2);
+ const char *cKey = env->GetStringUTFChars(jKey, 0);
+ std::string stdCKey(cKey);
+ env->ReleaseStringUTFChars(jKey, cKey);
+
+ // value
+ jstring jValue = (jstring)env->GetObjectArrayElement(responseHeadersArray, i * 2 + 1);
+ const char *cValue = env->GetStringUTFChars(jValue, 0);
+ std::string stdCValue(cValue);
+ env->ReleaseStringUTFChars(jValue, cValue);
+
+ std::pair<std::string,std::string> keyValue(stdCKey, stdCValue);
+ sResponse.responseHeaders.push_back(keyValue);
+ }
+ }
}
}
CheckAndLogJavaException(*env);
return sResponse;
}
« no previous file with comments | « no previous file | libadblockplus-android/jni/Utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld