summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed <ggayed>2009-10-03 01:47:55 +0000
committerGrant Gayed <ggayed>2009-10-03 01:47:55 +0000
commitf7f1dba87199260397b55de5f4e77818bcad3cd8 (patch)
tree9a8879dc65e83b539406cdd51014a207d12ab224
parent056762a1d7c74e75bfac132d1e756819b6f3b39e (diff)
downloadeclipse.platform.swt-f7f1dba87199260397b55de5f4e77818bcad3cd8.tar.gz
eclipse.platform.swt-f7f1dba87199260397b55de5f4e77818bcad3cd8.tar.xz
eclipse.platform.swt-f7f1dba87199260397b55de5f4e77818bcad3cd8.zip
*** empty log message ***
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java20
5 files changed, 87 insertions, 53 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java
index 12cd254102..59cb2ae8d5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java
@@ -821,26 +821,28 @@ public boolean setUrl(String url, String postData, String[] headers) {
if (headers != null) {
for (int i = 0; i < headers.length; i++) {
String current = headers[i];
- int index = current.indexOf(':');
- if (index != -1) {
- String key = current.substring(0, index).trim();
- String value = current.substring(index + 1).trim();
- if (key.length() > 0 && value.length() > 0) {
- if (key.equals(USER_AGENT)) {
- /*
- * Feature of Safari. The user-agent header value cannot be overridden
- * here. The workaround is to temporarily set the value on the WebView
- * and then remove it after the loading of the request has begun.
- */
- int string = createNSString(value);
- Cocoa.objc_msgSend(webView, Cocoa.S_setCustomUserAgent, string);
- OS.CFRelease (string);
- } else {
- int keyString = createNSString(key);
- int valueString = createNSString(value);
- Cocoa.objc_msgSend(request, Cocoa.S_setValueForHTTPHeaderField, keyString, valueString);
- OS.CFRelease (valueString);
- OS.CFRelease (keyString);
+ if (current != null) {
+ int index = current.indexOf(':');
+ if (index != -1) {
+ String key = current.substring(0, index).trim();
+ String value = current.substring(index + 1).trim();
+ if (key.length() > 0 && value.length() > 0) {
+ if (key.equals(USER_AGENT)) {
+ /*
+ * Feature of Safari. The user-agent header value cannot be overridden
+ * here. The workaround is to temporarily set the value on the WebView
+ * and then remove it after the loading of the request has begun.
+ */
+ int string = createNSString(value);
+ Cocoa.objc_msgSend(webView, Cocoa.S_setCustomUserAgent, string);
+ OS.CFRelease (string);
+ } else {
+ int keyString = createNSString(key);
+ int valueString = createNSString(value);
+ Cocoa.objc_msgSend(request, Cocoa.S_setValueForHTTPHeaderField, keyString, valueString);
+ OS.CFRelease (valueString);
+ OS.CFRelease (keyString);
+ }
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java
index 98348e136f..a3f2ce5c62 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java
@@ -528,20 +528,22 @@ public boolean setUrl(String url, String postData, String[] headers) {
if (headers != null) {
for (int i = 0; i < headers.length; i++) {
String current = headers[i];
- int index = current.indexOf(':');
- if (index != -1) {
- String key = current.substring(0, index).trim();
- String value = current.substring(index + 1).trim();
- if (key.length() > 0 && value.length() > 0) {
- if (key.equals(USER_AGENT)) {
- /*
- * Feature of Safari. The user-agent header value cannot be overridden
- * here. The workaround is to temporarily set the value on the WebView
- * and then remove it after the loading of the request has begun.
- */
- webView.setCustomUserAgent(NSString.stringWith(value));
- } else {
- request.setValue(NSString.stringWith(value), NSString.stringWith(key));
+ if (current != null) {
+ int index = current.indexOf(':');
+ if (index != -1) {
+ String key = current.substring(0, index).trim();
+ String value = current.substring(index + 1).trim();
+ if (key.length() > 0 && value.length() > 0) {
+ if (key.equals(USER_AGENT)) {
+ /*
+ * Feature of Safari. The user-agent header value cannot be overridden
+ * here. The workaround is to temporarily set the value on the WebView
+ * and then remove it after the loading of the request has begun.
+ */
+ webView.setCustomUserAgent(NSString.stringWith(value));
+ } else {
+ request.setValue(NSString.stringWith(value), NSString.stringWith(key));
+ }
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
index bd96efab5f..3b1bdf776f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
@@ -948,7 +948,6 @@ public void setJavascriptEnabled (boolean enabled) {
/**
* Renders a string containing HTML. The rendering of the content occurs asynchronously.
- *
* <p>
* The html parameter is Unicode encoded since it is a java <code>String</code>.
* As a result, the HTML meta tag charset should not be set. The charset is implied
@@ -994,6 +993,7 @@ public boolean setText (String html) {
* </ul>
*
* @see #getUrl
+ * @see #setUrl(String,String,String[])
*
* @since 3.0
*/
@@ -1002,6 +1002,32 @@ public boolean setUrl (String url) {
return setUrl (url, null, null);
}
+/**
+ * Begins loading a URL. The loading of its content occurs asynchronously.
+ * <p>
+ * If the URL causes an HTTP request to be initiated then the provided
+ * <code>postData</code> and <code>header</code> arguments, if any, are
+ * sent with the request. A value in the <code>headers</code> argument
+ * must be a name-value pair with a colon separator in order to be sent
+ * (for example: "<code>user-agent: custom</code>").
+ *
+ * @param url the URL to be loaded
+ * @param postData post data to be sent with the request, or <code>null</code>
+ * @param headers header lines to be sent with the request, or <code>null</code>
+ *
+ * @return true if the operation was successful and false otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the url is null</li>
+ * </ul>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.6
+ */
public boolean setUrl (String url, String postData, String[] headers) {
checkWidget();
if (url == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
index ae1d79705b..fb9e753215 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
@@ -1047,15 +1047,17 @@ boolean navigate(String url, String postData, String headers[], boolean silent)
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < headers.length; i++) {
String current = headers[i];
- int sep = current.indexOf(':');
- if (sep != -1) {
- String key = current.substring(0, sep).trim();
- String value = current.substring(sep + 1).trim();
- if (key.length() > 0 && value.length() > 0) {
- buffer.append(key);
- buffer.append(':');
- buffer.append(value);
- buffer.append("\r\n");
+ if (current != null) {
+ int sep = current.indexOf(':');
+ if (sep != -1) {
+ String key = current.substring(0, sep).trim();
+ String value = current.substring(sep + 1).trim();
+ if (key.length() > 0 && value.length() > 0) {
+ buffer.append(key);
+ buffer.append(':');
+ buffer.append(value);
+ buffer.append("\r\n");
+ }
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
index 0c671997c1..674edba9e5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
@@ -2429,15 +2429,17 @@ public boolean setUrl (String url, String postData, String[] headers) {
StringBuffer buffer = new StringBuffer ();
for (int i = 0; i < headers.length; i++) {
String current = headers[i];
- int sep = current.indexOf (':');
- if (sep != -1) {
- String key = current.substring (0, sep).trim ();
- String value = current.substring (sep + 1).trim ();
- if (key.length () > 0 && value.length () > 0) {
- buffer.append (key);
- buffer.append (':');
- buffer.append (value);
- buffer.append ("\r\n");
+ if (current != null) {
+ int sep = current.indexOf (':');
+ if (sep != -1) {
+ String key = current.substring (0, sep).trim ();
+ String value = current.substring (sep + 1).trim ();
+ if (key.length () > 0 && value.length () > 0) {
+ buffer.append (key);
+ buffer.append (':');
+ buffer.append (value);
+ buffer.append ("\r\n");
+ }
}
}
}