Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2017-12-01 20:01:17 +0000
committerLeo Ufimtsev2017-12-12 19:23:53 +0000
commitd8fca1df5fd4712c60aca821d48bec6f9359f1a4 (patch)
treecd628bab93072665a9e8b4c2f496b9fe9623d621 /bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
parente4ea137643762dd3e38d38276d52c49d8a5b8aec (diff)
downloadeclipse.platform.swt-d8fca1df5fd4712c60aca821d48bec6f9359f1a4.tar.gz
eclipse.platform.swt-d8fca1df5fd4712c60aca821d48bec6f9359f1a4.tar.xz
eclipse.platform.swt-d8fca1df5fd4712c60aca821d48bec6f9359f1a4.zip
Bug 527738 [Webkit2] implement setUrl(...POST..) support. (snippet 330)
When setURL contains POST data, bypass the Webkit2 API and use the Java API (HttpURLConnection) to perform the request. Set the URL globally so that when calling setText with the response string, any relative paths can be resolved using the base URL. This implementation does not currently support Webkit configured proxies and there may be issues with detecting various signals/listeners that operate on request/response objects given that these are handled by the Java side. Tested against Snippet330. --- Leo's modifications: Patchest 9 notes: - Added g_bytes_unref() to prevent memory leakage. - Making g_bytes_* dynamic otherwise we'll get jvm crash on gtk2. (g_byte* introduced in glib 2.32, but gtk2 only has glib 2.26(ish)). - Move data type conversion logic into one place. (html converted where it's used) - Reduced size of if statment, it was scary. - Add scope to code for clarity. - Don't touch this.postData & this.headers, they're only used by webkit1. Webkit2 shouldn't touch what it doesn't use. - Added if (Webkit1) guards around variables only used by webkit1. - Refactoring. - Avoid passing null value to webkit_web_view_load_bytes(.) if connection is not HTML. - Instead of passing empty array to encoding type, pass array with only a single 0. - Modified Snippet330.java to include some more examples for better testing and learning. - Verified: - against (modified) Snippet330 - jUnit tests. (w1/w2) ... Patchset 15: - Added counter support to setText(..) as a long setURI() could override a setText() call. Change-Id: Ic93747083af6af9933af3ca52149a1fb6e894d2c Signed-off-by: Roland Grunberg <rgrunber@redhat.com> Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 79cc73579d..9fca585520 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -2719,6 +2719,41 @@ public static final void g_object_unref(long /*int*/ object) {
lock.unlock();
}
}
+
+
+/**
+ * @method flags=dynamic
+ * @param data cast=(gconstpointer)
+ * @param size cast=(gsize)
+ */
+public static final native long /*int*/ _g_bytes_new (byte [] data, long /*int*/ size);
+public static final long /*int*/ g_bytes_new (byte [] data, long /*int*/ size) {
+ assert GTK3;
+ // Since glib 2.32. (gtk2.24 = glib2.28)
+ lock.lock();
+ try {
+ return _g_bytes_new (data, size);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/**
+ * @method flags=dynamic
+ * @param gBytes cast=(GBytes *)
+ */
+public static final native void _g_bytes_unref (long /*int*/ gBytes);
+public static final void g_bytes_unref (long /*int*/ gBytes) {
+ // Since glib 2.32. (gtk2.24 = glib2.28)
+ assert GTK3;
+ lock.lock();
+ try {
+ _g_bytes_unref (gBytes);
+ } finally {
+ lock.unlock();
+ }
+}
+
/** @param string cast=(const gchar *),flags=no_out */
public static final native int _g_quark_from_string(byte[] string);
public static final int g_quark_from_string(byte[] string) {

Back to the top