aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2014-01-22 21:31:58 +0100
committerManolo Carrasco <manolo@apache.org>2014-01-22 21:31:58 +0100
commitf4b20ca9e43b603979fbe89d73d8c662dbd01af2 (patch)
treed6bdb6885a88eda2bea20aa165b72ab2f85cbc31
parentaffdffa9897b1200257404f36c328c677255bfb5 (diff)
downloadgwtquery-f4b20ca9e43b603979fbe89d73d8c662dbd01af2.tar.gz
gwtquery-f4b20ca9e43b603979fbe89d73d8c662dbd01af2.zip
adding some configuration flags
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java
index 015dcc94..166fa3b4 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java
@@ -29,13 +29,27 @@ public class AjaxTransportJre implements AjaxTransport {
private static CookieManager cookieManager = CookieManager.getInstance();
- public static boolean debugOutput = false;
+ private static boolean debugOutput = false;
+
+ private static boolean followRedirections = true;
public static void enableCORS(String domain) {
localDomain = domain;
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
}
+ public static void enableDebug(boolean b) {
+ debugOutput = b;
+ }
+
+ public static void enableCookies(boolean b) {
+ cookieManager = b ? CookieManager.getInstance() : null;
+ }
+
+ public static void enableRedirections(boolean b) {
+ followRedirections = b;
+ }
+
private final String USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0";
private final String jsonpCbRexp = "(?ms)^.*jre_callback\\((.*)\\).*$";
@@ -95,12 +109,17 @@ public class AjaxTransportJre implements AjaxTransport {
URL u = new URL(url);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
+
+ c.setInstanceFollowRedirects(followRedirections);
+
c.setRequestMethod(s.getType());
c.setRequestProperty("User-Agent", USER_AGENT);
if (s.getUsername() != null && s.getPassword() != null) {
c.setRequestProperty ("Authorization", "Basic " + Base64Utils.toBase64((s.getUsername() + ":" + s.getPassword()).getBytes()));
}
- cookieManager.setCookies(c);
+ if (cookieManager != null) {
+ cookieManager.setCookies(c);
+ }
boolean isCORS = cors && localDomain != null && !s.getUrl().contains(localDomain);
if (isCORS) {
@@ -160,8 +179,11 @@ public class AjaxTransportJre implements AjaxTransport {
response.append(inputLine + "\n");
}
in.close();
-
- cookieManager.storeCookies(c);
+
+ if (cookieManager != null) {
+ cookieManager.storeCookies(c);
+ }
+
return new ResponseJre(code, c.getResponseMessage(), response.toString(), c.getHeaderFields());
}