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; |
} |