aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java8
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java23
2 files changed, 18 insertions, 13 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java
index 7b472ba5..e11e5923 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java
@@ -44,8 +44,6 @@ public class Ajax extends GQuery {
Promise getXhr(Settings settings);
}
- static AjaxTransport transport = GQ.getAjaxTransport();
-
/**
* Ajax Settings object
*/
@@ -137,11 +135,11 @@ public class Ajax extends GQuery {
Promise ret = null;
if ("jsonp".equalsIgnoreCase(dataType)) {
- ret = transport.getJsonP(settings);
+ ret = GQ.getAjaxTransport().getJsonP(settings);
} else if ("loadscript".equalsIgnoreCase(dataType)){
- ret = transport.getLoadScript(settings);
+ ret = GQ.getAjaxTransport().getLoadScript(settings);
} else {
- ret = transport.getXhr(settings)
+ ret = GQ.getAjaxTransport().getXhr(settings)
.then(new Function() {
public Object f(Object...args) {
Response response = arguments(0);
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 d6f2fcdb..4ac9ed1a 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
@@ -4,6 +4,7 @@ package com.google.gwt.query.vm;
import java.io.BufferedReader;
import java.io.DataOutputStream;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -177,19 +178,25 @@ public class AjaxTransportJre implements AjaxTransport {
}
}
- BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream()));
- String inputLine;
- StringBuffer response = new StringBuffer();
- while ((inputLine = in.readLine()) != null) {
- response.append(inputLine + "\n");
+ String payload = "";
+
+ InputStream is = code >= 400 ? c.getErrorStream() : c.getInputStream();
+ if (is != null) {
+ BufferedReader in = new BufferedReader(new InputStreamReader(is));
+ String inputLine;
+ StringBuffer response = new StringBuffer();
+ while ((inputLine = in.readLine()) != null) {
+ response.append(inputLine + "\n");
+ }
+ in.close();
+ payload = response.toString();
}
- in.close();
-
+
if (cookieManager != null) {
cookieManager.storeCookies(c);
}
- return new ResponseJre(code, c.getResponseMessage(), response.toString(), c.getHeaderFields());
+ return new ResponseJre(code, c.getResponseMessage(), payload, c.getHeaderFields());
}
private void debugRequest(HttpURLConnection c, String payload) {