Exemple #1
0
void DumpResponseContents(CefRefPtr<CefResponse> response, std::string& str)
{
  std::stringstream ss;
  //ss << "MIME: " << response->GetMimeType() << "\n";
  CefResponse::HeaderMap headerMap;
  response->GetHeaderMap(headerMap);
  if(headerMap.size() > 0) 
  {
    ss << "\nHeaders:";
    CefResponse::HeaderMap::const_iterator it = headerMap.begin();
    for(; it != headerMap.end(); ++it) 
    {
      ss << "\n\t" << std::string((*it).first) << ": " <<
          std::string((*it).second);
    }
  }
  str = ss.str();  
}
JNIEXPORT void JNICALL Java_org_cef_network_CefResponse_1N_N_1GetHeaderMap
  (JNIEnv *env, jobject obj, jobject jheaderMap) {
  CefRefPtr<CefResponse> response = GetCefFromJNIObject<CefResponse>(env, obj, "CefResponse");
  if (!response)
    return;  
  CefResponse::HeaderMap headerMap;
  response->GetHeaderMap(headerMap);

  for (CefResponse::HeaderMap::iterator iter = headerMap.begin(); iter != headerMap.end(); ++iter) {
    jstring jkey = NewJNIString(env, iter->first);
    jstring jvalue = NewJNIString(env, iter->second);
    jobject returnIgn = NULL;
    JNI_CALL_METHOD(env,
                    jheaderMap,
                    "put",
                    "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                    Object,
                    returnIgn,
                    jkey,
                    jvalue);
    UNUSED(returnIgn);
  }
}