Requestor
A Modern HTTP Client API for GWT, Requestor offers all features needed for a current robust AJAX application. It is pleasant to use and fully configurable and extensible.
Preview
Requesting is now simple and nice.
requestor.req("http://httpbin.org/ip").get(String.class).done(new DoneCallback<String>() {
public void onDone(String result) {
Window.alert(result);
}
});
With Java 8 support, it will be really cool!
requestor.req("http://httpbin.org/ip").get(String.class).done(Window::alert);
The low-level RequestBuilder way would be...
/* Original GWT RequestBuilder approach */
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, "http://httpbin.org/ip");
rb.setCallback(new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
String result = response.getText();
Window.alert(result);
}
@Override
public void onError(Request request, Throwable exception) {
// ...
}
});
try {
rb.send();
} catch (RequestException e) {
// ...
}
Make a request is a trivial task and now you can do it healthily. :)
Requesting will never be boring again!
Features
- Promises (integrate any promise library)
- Fluent API
- Full support to Form requests (urlencoded or multipart)
- Full support to raw binary data (File, Blob, ArrayBuffer, Json, Document)
- Progress monitoring of uploads and downloads
- Uri Parsing
- Uri Building
- Basic and Digest authentication (nicely supporting CORS)
- OAuth2
- Extremely easy to implement any custom authentication
- Headers API
- Filters (enhance requests and responses)
- Interceptors (transform payloads)
- Auto JSON serialization for POJOs, JavaBean Interfaces and Overlay types
- Integrated to the AutoBean Framework
- Integrated to gwt-jackson
- Integrated to TurboGWT
- Handle multiple serialization of the same java type for different media types
- Customizable request dispatching (support for caching and synchronization)
Browser Support
Almost all features are working perfectly in all modern browsers, except:
- Binary data manipulation is not supported by IE9- and Opera Mini
- CORS is poorly supported by IE9- and Opera Mini
Examples
Documentation
Community
Latest Release
0.2.0 (18 Feb 2015)
Installation
The minimal installation requires two dependencies, the core API and some implementation. The default implementation is requestor-gdeferred, which exposes GDeferred's Promise API.
<dependency>
<groupId>io.reinert.gdeferred</groupId>
<artifactId>gdeferred</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>io.reinert.requestor.impl</groupId>
<artifactId>requestor-gdeferred</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>io.reinert.requestor.core</groupId>
<artifactId>requestor-api</artifactId>
<version>0.2.0</version>
</dependency>
To make requestor available to your GWT project, import the implementation's module.
<inherits name="io.reinert.requestor.RequestorByGDeferred"/>
Read the Getting Started wiki page for more information.
Using SNAPSHOT versions
If you want to use the latest snapshot, you need to add the sonatype snapshot repository to your POM.
<repositories>
...
<repository>
<id>oss-sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
...
</repositories>
License
Requestor is freely distributable under the Apache 2.0 License