From 3446a2748ad4c823847d46241ec28335b0f29e52 Mon Sep 17 00:00:00 2001 From: aalku Date: Sun, 14 Jan 2024 13:03:50 +0100 Subject: [PATCH 1/3] CefResponse with access to charset --- java/org/cef/network/CefResponse.java | 10 ++++++++++ java/org/cef/network/CefResponse_N.java | 21 +++++++++++++++++++++ native/CefResponse_N.h | 16 ++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/java/org/cef/network/CefResponse.java b/java/org/cef/network/CefResponse.java index fe705ba1..43e61e29 100644 --- a/java/org/cef/network/CefResponse.java +++ b/java/org/cef/network/CefResponse.java @@ -82,6 +82,16 @@ public static final CefResponse create() { */ public abstract void setMimeType(String mimeType); + /** + * Get the response charset. + */ + public abstract String getCharset(); + + /** + * Set the response charset. + */ + public abstract void setCharset(String charset); + /** * Get the value for the specified response header field. Use getHeaderMap instead if there * might be multiple values. diff --git a/java/org/cef/network/CefResponse_N.java b/java/org/cef/network/CefResponse_N.java index 60e25256..12dfcdde 100644 --- a/java/org/cef/network/CefResponse_N.java +++ b/java/org/cef/network/CefResponse_N.java @@ -131,6 +131,25 @@ public void setMimeType(String mimeType) { } } + @Override + public String getCharset() { + try { + return N_GetCharset(N_CefHandle); + } catch (UnsatisfiedLinkError ule) { + ule.printStackTrace(); + } + return null; + } + + @Override + public void setCharset(String charset) { + try { + N_SetCharset(N_CefHandle, charset); + } catch (UnsatisfiedLinkError ule) { + ule.printStackTrace(); + } + } + @Override public String getHeaderByName(String name) { try { @@ -179,6 +198,8 @@ public void setHeaderMap(Map headerMap) { private final native void N_SetStatusText(long self, String statusText); private final native String N_GetMimeType(long self); private final native void N_SetMimeType(long self, String mimeType); + private final native String N_GetCharset(long self); + private final native void N_SetCharset(long self, String charset); private final native String N_GetHeaderByName(long self, String name); private final native void N_SetHeaderByName( long self, String name, String value, boolean overwrite); diff --git a/native/CefResponse_N.h b/native/CefResponse_N.h index 9fd93c04..b51338dc 100644 --- a/native/CefResponse_N.h +++ b/native/CefResponse_N.h @@ -107,6 +107,22 @@ Java_org_cef_network_CefResponse_1N_N_1SetMimeType(JNIEnv*, jlong, jstring); +/* + * Class: org_cef_network_CefResponse_N + * Method: N_GetCharset + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_cef_network_CefResponse_1N_N_1GetCharset + (JNIEnv *, jobject, jlong); + +/* + * Class: org_cef_network_CefResponse_N + * Method: N_SetCharset + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_cef_network_CefResponse_1N_N_1SetCharset + (JNIEnv *, jobject, jlong, jstring); + /* * Class: org_cef_network_CefResponse_N * Method: N_GetHeaderByName From 848e6fbab56d1a9a63c3fe8475bbc5730c73c9f4 Mon Sep 17 00:00:00 2001 From: aalku Date: Sun, 14 Jan 2024 16:31:16 +0100 Subject: [PATCH 2/3] Cpp too (CefResponse.setCharset()) --- native/CefResponse_N.cpp | 391 +++++++++++++++++++++------------------ 1 file changed, 206 insertions(+), 185 deletions(-) diff --git a/native/CefResponse_N.cpp b/native/CefResponse_N.cpp index de1b32a9..9bda568b 100644 --- a/native/CefResponse_N.cpp +++ b/native/CefResponse_N.cpp @@ -1,185 +1,206 @@ -// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "CefResponse_N.h" - -#include "include/cef_response.h" - -#include "jni_scoped_helpers.h" -#include "jni_util.h" - -namespace { - -const char kCefClassName[] = "CefResponse"; - -CefRefPtr GetSelf(jlong self) { - return reinterpret_cast(self); -} - -} // namespace - -JNIEXPORT jobject JNICALL -Java_org_cef_network_CefResponse_1N_N_1Create(JNIEnv* env, jclass cls) { - CefRefPtr response = CefResponse::Create(); - ScopedJNIResponse jresponse(env, response); - return jresponse.Release(); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1Dispose(JNIEnv* env, - jobject obj, - jlong self) { - SetCefForJNIObject(env, obj, nullptr, kCefClassName); -} - -JNIEXPORT jboolean JNICALL -Java_org_cef_network_CefResponse_1N_N_1IsReadOnly(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return JNI_FALSE; - return response->IsReadOnly() ? JNI_TRUE : JNI_FALSE; -} - -JNIEXPORT jobject JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetError(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIErrorCode(env, response->GetError()); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetError(JNIEnv* env, - jobject obj, - jlong self, - jobject jerrorCode) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - - if (!jerrorCode) - return; - response->SetError(GetJNIErrorCode(env, jerrorCode)); -} - -JNIEXPORT jint JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetStatus(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return 0; - return response->GetStatus(); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetStatus(JNIEnv* env, - jobject obj, - jlong self, - jint jstatus) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - return response->SetStatus(jstatus); -} - -JNIEXPORT jstring JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetStatusText(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIString(env, response->GetStatusText()); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetStatusText(JNIEnv* env, - jobject obj, - jlong self, - jstring jstatus) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - response->SetStatusText(GetJNIString(env, jstatus)); -} - -JNIEXPORT jstring JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetMimeType(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIString(env, response->GetMimeType()); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetMimeType(JNIEnv* env, - jobject obj, - jlong self, - jstring jmimeType) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - response->SetMimeType(GetJNIString(env, jmimeType)); -} - -JNIEXPORT jstring JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetHeaderByName(JNIEnv* env, - jobject obj, - jlong self, - jstring jname) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIString(env, response->GetHeaderByName(GetJNIString(env, jname))); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetHeaderByName(JNIEnv* env, - jobject obj, - jlong self, - jstring jname, - jstring jvalue, - jboolean joverride) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - return response->SetHeaderByName(GetJNIString(env, jname), - GetJNIString(env, jvalue), - joverride != JNI_FALSE); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetHeaderMap(JNIEnv* env, - jobject obj, - jlong self, - jobject jheaderMap) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - - CefResponse::HeaderMap headerMap; - response->GetHeaderMap(headerMap); - SetJNIStringMultiMap(env, jheaderMap, headerMap); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetHeaderMap(JNIEnv* env, - jobject obj, - jlong self, - jobject jheaderMap) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - - CefResponse::HeaderMap headerMap; - GetJNIStringMultiMap(env, jheaderMap, headerMap); - response->SetHeaderMap(headerMap); -} +// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#include "CefResponse_N.h" + +#include "include/cef_response.h" + +#include "jni_scoped_helpers.h" +#include "jni_util.h" + +namespace { + +const char kCefClassName[] = "CefResponse"; + +CefRefPtr GetSelf(jlong self) { + return reinterpret_cast(self); +} + +} // namespace + +JNIEXPORT jobject JNICALL +Java_org_cef_network_CefResponse_1N_N_1Create(JNIEnv* env, jclass cls) { + CefRefPtr response = CefResponse::Create(); + ScopedJNIResponse jresponse(env, response); + return jresponse.Release(); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1Dispose(JNIEnv* env, + jobject obj, + jlong self) { + SetCefForJNIObject(env, obj, nullptr, kCefClassName); +} + +JNIEXPORT jboolean JNICALL +Java_org_cef_network_CefResponse_1N_N_1IsReadOnly(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return JNI_FALSE; + return response->IsReadOnly() ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT jobject JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetError(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIErrorCode(env, response->GetError()); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetError(JNIEnv* env, + jobject obj, + jlong self, + jobject jerrorCode) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + + if (!jerrorCode) + return; + response->SetError(GetJNIErrorCode(env, jerrorCode)); +} + +JNIEXPORT jint JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetStatus(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return 0; + return response->GetStatus(); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetStatus(JNIEnv* env, + jobject obj, + jlong self, + jint jstatus) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + return response->SetStatus(jstatus); +} + +JNIEXPORT jstring JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetStatusText(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIString(env, response->GetStatusText()); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetStatusText(JNIEnv* env, + jobject obj, + jlong self, + jstring jstatus) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + response->SetStatusText(GetJNIString(env, jstatus)); +} + +JNIEXPORT jstring JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetMimeType(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIString(env, response->GetMimeType()); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetMimeType(JNIEnv* env, + jobject obj, + jlong self, + jstring jmimeType) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + response->SetMimeType(GetJNIString(env, jmimeType)); +} + +JNIEXPORT jstring JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetCharset(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIString(env, response->GetCharset()); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetCharset(JNIEnv* env, + jobject obj, + jlong self, + jstring jmimeType) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + response->SetCharset(GetJNIString(env, jmimeType)); +} + +JNIEXPORT jstring JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetHeaderByName(JNIEnv* env, + jobject obj, + jlong self, + jstring jname) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIString(env, response->GetHeaderByName(GetJNIString(env, jname))); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetHeaderByName(JNIEnv* env, + jobject obj, + jlong self, + jstring jname, + jstring jvalue, + jboolean joverride) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + return response->SetHeaderByName(GetJNIString(env, jname), + GetJNIString(env, jvalue), + joverride != JNI_FALSE); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetHeaderMap(JNIEnv* env, + jobject obj, + jlong self, + jobject jheaderMap) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + + CefResponse::HeaderMap headerMap; + response->GetHeaderMap(headerMap); + SetJNIStringMultiMap(env, jheaderMap, headerMap); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetHeaderMap(JNIEnv* env, + jobject obj, + jlong self, + jobject jheaderMap) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + + CefResponse::HeaderMap headerMap; + GetJNIStringMultiMap(env, jheaderMap, headerMap); + response->SetHeaderMap(headerMap); +} From 1dbf8281072e6a0b3520a82a6fffbcc35d8d821b Mon Sep 17 00:00:00 2001 From: aalku Date: Sun, 14 Jan 2024 16:34:57 +0100 Subject: [PATCH 3/3] LF --- native/CefResponse_N.cpp | 412 +++++++++++++++++++-------------------- 1 file changed, 206 insertions(+), 206 deletions(-) diff --git a/native/CefResponse_N.cpp b/native/CefResponse_N.cpp index 9bda568b..2a1e7f71 100644 --- a/native/CefResponse_N.cpp +++ b/native/CefResponse_N.cpp @@ -1,206 +1,206 @@ -// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "CefResponse_N.h" - -#include "include/cef_response.h" - -#include "jni_scoped_helpers.h" -#include "jni_util.h" - -namespace { - -const char kCefClassName[] = "CefResponse"; - -CefRefPtr GetSelf(jlong self) { - return reinterpret_cast(self); -} - -} // namespace - -JNIEXPORT jobject JNICALL -Java_org_cef_network_CefResponse_1N_N_1Create(JNIEnv* env, jclass cls) { - CefRefPtr response = CefResponse::Create(); - ScopedJNIResponse jresponse(env, response); - return jresponse.Release(); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1Dispose(JNIEnv* env, - jobject obj, - jlong self) { - SetCefForJNIObject(env, obj, nullptr, kCefClassName); -} - -JNIEXPORT jboolean JNICALL -Java_org_cef_network_CefResponse_1N_N_1IsReadOnly(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return JNI_FALSE; - return response->IsReadOnly() ? JNI_TRUE : JNI_FALSE; -} - -JNIEXPORT jobject JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetError(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIErrorCode(env, response->GetError()); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetError(JNIEnv* env, - jobject obj, - jlong self, - jobject jerrorCode) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - - if (!jerrorCode) - return; - response->SetError(GetJNIErrorCode(env, jerrorCode)); -} - -JNIEXPORT jint JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetStatus(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return 0; - return response->GetStatus(); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetStatus(JNIEnv* env, - jobject obj, - jlong self, - jint jstatus) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - return response->SetStatus(jstatus); -} - -JNIEXPORT jstring JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetStatusText(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIString(env, response->GetStatusText()); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetStatusText(JNIEnv* env, - jobject obj, - jlong self, - jstring jstatus) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - response->SetStatusText(GetJNIString(env, jstatus)); -} - -JNIEXPORT jstring JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetMimeType(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIString(env, response->GetMimeType()); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetMimeType(JNIEnv* env, - jobject obj, - jlong self, - jstring jmimeType) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - response->SetMimeType(GetJNIString(env, jmimeType)); -} - -JNIEXPORT jstring JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetCharset(JNIEnv* env, - jobject obj, - jlong self) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIString(env, response->GetCharset()); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetCharset(JNIEnv* env, - jobject obj, - jlong self, - jstring jmimeType) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - response->SetCharset(GetJNIString(env, jmimeType)); -} - -JNIEXPORT jstring JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetHeaderByName(JNIEnv* env, - jobject obj, - jlong self, - jstring jname) { - CefRefPtr response = GetSelf(self); - if (!response) - return nullptr; - return NewJNIString(env, response->GetHeaderByName(GetJNIString(env, jname))); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetHeaderByName(JNIEnv* env, - jobject obj, - jlong self, - jstring jname, - jstring jvalue, - jboolean joverride) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - return response->SetHeaderByName(GetJNIString(env, jname), - GetJNIString(env, jvalue), - joverride != JNI_FALSE); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1GetHeaderMap(JNIEnv* env, - jobject obj, - jlong self, - jobject jheaderMap) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - - CefResponse::HeaderMap headerMap; - response->GetHeaderMap(headerMap); - SetJNIStringMultiMap(env, jheaderMap, headerMap); -} - -JNIEXPORT void JNICALL -Java_org_cef_network_CefResponse_1N_N_1SetHeaderMap(JNIEnv* env, - jobject obj, - jlong self, - jobject jheaderMap) { - CefRefPtr response = GetSelf(self); - if (!response) - return; - - CefResponse::HeaderMap headerMap; - GetJNIStringMultiMap(env, jheaderMap, headerMap); - response->SetHeaderMap(headerMap); -} +// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#include "CefResponse_N.h" + +#include "include/cef_response.h" + +#include "jni_scoped_helpers.h" +#include "jni_util.h" + +namespace { + +const char kCefClassName[] = "CefResponse"; + +CefRefPtr GetSelf(jlong self) { + return reinterpret_cast(self); +} + +} // namespace + +JNIEXPORT jobject JNICALL +Java_org_cef_network_CefResponse_1N_N_1Create(JNIEnv* env, jclass cls) { + CefRefPtr response = CefResponse::Create(); + ScopedJNIResponse jresponse(env, response); + return jresponse.Release(); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1Dispose(JNIEnv* env, + jobject obj, + jlong self) { + SetCefForJNIObject(env, obj, nullptr, kCefClassName); +} + +JNIEXPORT jboolean JNICALL +Java_org_cef_network_CefResponse_1N_N_1IsReadOnly(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return JNI_FALSE; + return response->IsReadOnly() ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT jobject JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetError(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIErrorCode(env, response->GetError()); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetError(JNIEnv* env, + jobject obj, + jlong self, + jobject jerrorCode) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + + if (!jerrorCode) + return; + response->SetError(GetJNIErrorCode(env, jerrorCode)); +} + +JNIEXPORT jint JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetStatus(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return 0; + return response->GetStatus(); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetStatus(JNIEnv* env, + jobject obj, + jlong self, + jint jstatus) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + return response->SetStatus(jstatus); +} + +JNIEXPORT jstring JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetStatusText(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIString(env, response->GetStatusText()); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetStatusText(JNIEnv* env, + jobject obj, + jlong self, + jstring jstatus) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + response->SetStatusText(GetJNIString(env, jstatus)); +} + +JNIEXPORT jstring JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetMimeType(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIString(env, response->GetMimeType()); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetMimeType(JNIEnv* env, + jobject obj, + jlong self, + jstring jmimeType) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + response->SetMimeType(GetJNIString(env, jmimeType)); +} + +JNIEXPORT jstring JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetCharset(JNIEnv* env, + jobject obj, + jlong self) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIString(env, response->GetCharset()); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetCharset(JNIEnv* env, + jobject obj, + jlong self, + jstring jmimeType) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + response->SetCharset(GetJNIString(env, jmimeType)); +} + +JNIEXPORT jstring JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetHeaderByName(JNIEnv* env, + jobject obj, + jlong self, + jstring jname) { + CefRefPtr response = GetSelf(self); + if (!response) + return nullptr; + return NewJNIString(env, response->GetHeaderByName(GetJNIString(env, jname))); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetHeaderByName(JNIEnv* env, + jobject obj, + jlong self, + jstring jname, + jstring jvalue, + jboolean joverride) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + return response->SetHeaderByName(GetJNIString(env, jname), + GetJNIString(env, jvalue), + joverride != JNI_FALSE); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1GetHeaderMap(JNIEnv* env, + jobject obj, + jlong self, + jobject jheaderMap) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + + CefResponse::HeaderMap headerMap; + response->GetHeaderMap(headerMap); + SetJNIStringMultiMap(env, jheaderMap, headerMap); +} + +JNIEXPORT void JNICALL +Java_org_cef_network_CefResponse_1N_N_1SetHeaderMap(JNIEnv* env, + jobject obj, + jlong self, + jobject jheaderMap) { + CefRefPtr response = GetSelf(self); + if (!response) + return; + + CefResponse::HeaderMap headerMap; + GetJNIStringMultiMap(env, jheaderMap, headerMap); + response->SetHeaderMap(headerMap); +}