Adds getters to RequestBuilder so that the object returned from a delayed async RPC is actually useful.
Review by: jat
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2393 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/http/client/RequestBuilder.java b/user/src/com/google/gwt/http/client/RequestBuilder.java
index 2e6a19c..91ab448 100644
--- a/user/src/com/google/gwt/http/client/RequestBuilder.java
+++ b/user/src/com/google/gwt/http/client/RequestBuilder.java
@@ -72,6 +72,9 @@
private static final HTTPRequestImpl httpRequest = (HTTPRequestImpl) GWT.create(HTTPRequestImpl.class);
+ /**
+ * The callback to call when the request completes.
+ */
private RequestCallback callback;
/**
@@ -81,15 +84,18 @@
private Map<String, String> headers;
/**
- * HTTP method to use when opening an JavaScript XmlHttpRequest object
+ * HTTP method to use when opening a JavaScript XmlHttpRequest object.
*/
private final String httpMethod;
/**
- * Password to use when opening an JavaScript XmlHttpRequest object
+ * Password to use when opening a JavaScript XmlHttpRequest object.
*/
private String password;
+ /**
+ * Request data to use when sending a JavaScript XmlHttpRequest object.
+ */
private String requestData;
/**
@@ -98,12 +104,12 @@
private int timeoutMillis;
/**
- * URL to use when opening an JavaScript XmlHttpRequest object.
+ * URL to use when opening a JavaScript XmlHttpRequest object.
*/
private final String url;
/**
- * User to use when opening an JavaScript XmlHttpRequest object
+ * User to use when opening a JavaScript XmlHttpRequest object.
*/
private String user;
@@ -149,6 +155,75 @@
}
/**
+ * Returns the callback previously set by
+ * {@link #setCallback(RequestCallback)}, or <code>null</code> if no
+ * callback was set.
+ */
+ public RequestCallback getCallback() {
+ return callback;
+ }
+
+ /**
+ * Returns the value of a header previous set by
+ * {@link #setHeader(String, String)}, or <code>null</code> if no such
+ * header was set.
+ *
+ * @param header the name of the header
+ */
+ public String getHeader(String header) {
+ if (headers == null) {
+ return null;
+ }
+ return headers.get(header);
+ }
+
+ /**
+ * Returns the HTTP method specified in the constructor.
+ */
+ public String getHTTPMethod() {
+ return httpMethod;
+ }
+
+ /**
+ * Returns the password previously set by {@link #setPassword(String)}, or
+ * <code>null</code> if no password was set.
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Returns the requestData previously set by {@link #setRequestData(String)},
+ * or <code>null</code> if no requestData was set.
+ */
+ public String getRequestData() {
+ return requestData;
+ }
+
+ /**
+ * Returns the timeoutMillis previously set by {@link #setTimeoutMillis(int)},
+ * or <code>0</code> if no timeoutMillis was set.
+ */
+ public int getTimeoutMillis() {
+ return timeoutMillis;
+ }
+
+ /**
+ * Returns the HTTP URL specified in the constructor.
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * Returns the user previously set by {@link #setUser(String)}, or
+ * <code>null</code> if no user was set.
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
* Sends an HTTP request based on the current builder configuration. If no
* request headers have been set, the header "Content-Type" will be used with
* a value of "text/plain; charset=utf-8". You must call