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.cpp b/native/CefResponse_N.cpp index de1b32a9..2a1e7f71 100644 --- a/native/CefResponse_N.cpp +++ b/native/CefResponse_N.cpp @@ -130,6 +130,27 @@ Java_org_cef_network_CefResponse_1N_N_1SetMimeType(JNIEnv* env, 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, 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