|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.http.client.RequestBuilder
public class RequestBuilder
Builder for constructing Request
objects.
By default, this builder is restricted to building HTTP GET and POST requests
due to a bug in Safari's implementation of the XmlHttpRequest
object.
Please see http://bugs.webkit.org/show_bug.cgi?id=3812 for more details.
com.google.gwt.http.HTTP
.
<!-- --> <!-- Copyright 2007 Google Inc. --> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> <!-- may not use this file except in compliance with the License. You may --> <!-- may obtain a copy of the License at --> <!-- --> <!-- http://www.apache.org/licenses/LICENSE-2.0 --> <!-- --> <!-- Unless required by applicable law or agreed to in writing, software --> <!-- distributed under the License is distributed on an "AS IS" BASIS, --> <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or --> <!-- implied. License for the specific language governing permissions and --> <!-- limitations under the License. --> <module> <!-- other inherited modules, such as com.google.gwt.user.User --> <inherits name="com.google.gwt.http.HTTP"/> <!-- additional module settings --> </module>
Nested Class Summary | |
---|---|
static class |
RequestBuilder.Method
HTTP request method constants. |
Field Summary | |
---|---|
static RequestBuilder.Method |
GET
Specifies that the HTTP GET method should be used. |
static RequestBuilder.Method |
POST
Specifies that the HTTP POST method should be used. |
Constructor Summary | |
---|---|
|
RequestBuilder(RequestBuilder.Method httpMethod,
java.lang.String url)
Creates a builder using the parameters for configuration. |
protected |
RequestBuilder(java.lang.String httpMethod,
java.lang.String url)
Creates a builder using the parameters values for configuration. |
Method Summary | |
---|---|
Request |
sendRequest(java.lang.String requestData,
RequestCallback callback)
Sends an HTTP request based on the current builder configuration. |
void |
setHeader(java.lang.String header,
java.lang.String value)
Sets a request header with the given name and value. |
void |
setPassword(java.lang.String password)
Sets the password to use in the request URL. |
void |
setTimeoutMillis(int timeoutMillis)
Sets the number of milliseconds to wait for a request to complete. |
void |
setUser(java.lang.String user)
Sets the user name that will be used in the request URL. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final RequestBuilder.Method GET
public static final RequestBuilder.Method POST
Constructor Detail |
---|
public RequestBuilder(RequestBuilder.Method httpMethod, java.lang.String url)
httpMethod
- HTTP method to use for the requesturl
- URL that has already has already been encoded. Please see
URL.encode(String)
and
URL.encodeComponent(String)
for
how to do this.
java.lang.IllegalArgumentException
- if the httpMethod or URL are empty
java.lang.NullPointerException
- if the httpMethod or the URL are nullprotected RequestBuilder(java.lang.String httpMethod, java.lang.String url)
httpMethod
- HTTP method to use for the requesturl
- URL that has already has already been URL encoded. Please see
URL.encode(String)
and
URL.encodeComponent(String)
for
how to do this.
java.lang.IllegalArgumentException
- if the httpMethod or URL are empty
java.lang.NullPointerException
- if the httpMethod or the URL are null
WARNING:This method is provided in order to allow the creation of HTTP request other than GET and POST to be made. If this is done, the developer must accept that the behavior on Safari is undefined.
Method Detail |
---|
public Request sendRequest(java.lang.String requestData, RequestCallback callback) throws RequestException
requestData
- the data to send as part of the requestcallback
- the response handler to be notified when the request fails
or completes
Request
object that can be used to track the request
RequestException
public void setHeader(java.lang.String header, java.lang.String value)
header
- the name of the headervalue
- the value of the header
java.lang.NullPointerException
- if header or value are null
java.lang.IllegalArgumentException
- if header or value are the empty stringpublic void setPassword(java.lang.String password)
password
- password to use in the request URL
java.lang.IllegalArgumentException
- if the password is empty
java.lang.NullPointerException
- if the password is nullpublic void setTimeoutMillis(int timeoutMillis)
RequestCallback.onError(Request, Throwable)
method will be called on the callback instance given to the
sendRequest(String, RequestCallback)
method. The callback method will receive an instance of the
RequestTimeoutException
class as its
Throwable
argument.
timeoutMillis
- number of milliseconds to wait before canceling the
request, a value of zero disables timeouts
java.lang.IllegalArgumentException
- if the timeout value is negativepublic void setUser(java.lang.String user)
user
- user name to use
java.lang.IllegalArgumentException
- if the user is empty
java.lang.NullPointerException
- if the user is null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |