| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 sResponse.responseText = JniGetStringField(*env, | 79 sResponse.responseText = JniGetStringField(*env, |
| 80 serverResponseClass->Get(), *response, "response"); | 80 serverResponseClass->Get(), *response, "response"); |
| 81 | 81 |
| 82 // map headers | 82 // map headers |
| 83 jobjectArray responseHeadersArray = JniGetStringArrayField(*env, | 83 jobjectArray responseHeadersArray = JniGetStringArrayField(*env, |
| 84 serverResponseClass->Get(), *response, "headers"); | 84 serverResponseClass->Get(), *response, "headers"); |
| 85 | 85 |
| 86 if (responseHeadersArray) | 86 if (responseHeadersArray) |
| 87 { | 87 { |
| 88 int itemsCount = env->GetArrayLength(responseHeadersArray) / 2; | 88 int itemsCount = env->GetArrayLength(responseHeadersArray) / 2; |
| 89 for (int i=0; i<itemsCount; i++) | 89 for (int i = 0; i < itemsCount; i++) |
| 90 { | 90 { |
| 91 jstring jKey = (jstring)env->GetObjectArrayElement(responseHeadersArra
y, i * 2); | 91 jstring jKey = (jstring)env->GetObjectArrayElement(responseHeadersArra
y, i * 2); |
| 92 std::string stdKey = JniJavaToStdString(*env, jKey); | 92 std::string stdKey = JniJavaToStdString(*env, jKey); |
| 93 | 93 |
| 94 jstring jValue = (jstring)env->GetObjectArrayElement(responseHeadersAr
ray, i * 2 + 1); | 94 jstring jValue = (jstring)env->GetObjectArrayElement(responseHeadersAr
ray, i * 2 + 1); |
| 95 std::string stdValue = JniJavaToStdString(*env, jValue); | 95 std::string stdValue = JniJavaToStdString(*env, jValue); |
| 96 | 96 |
| 97 std::pair<std::string,std::string> keyValue(stdKey, stdValue); | 97 std::pair<std::string,std::string> keyValue(stdKey, stdValue); |
| 98 sResponse.responseHeaders.push_back(keyValue); | 98 sResponse.responseHeaders.push_back(keyValue); |
| 99 } | 99 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 121 static JNINativeMethod methods[] = | 121 static JNINativeMethod methods[] = |
| 122 { | 122 { |
| 123 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, | 123 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, |
| 124 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 124 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_WebRequest
_registerNatives(JNIEnv *env, jclass clazz) | 127 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_WebRequest
_registerNatives(JNIEnv *env, jclass clazz) |
| 128 { | 128 { |
| 129 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 129 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
| 130 } | 130 } |
| LEFT | RIGHT |