Fluent interface for easy HTTP requests to web servers (GET
, POST
, PUT
or DELETE
)
- Include one of the JARs in your
libs
folder - or
- Copy the Java package to your project's source folder
- or
- Create a new library project from this repository and reference it in your project
new WebRequest().get().to("http://www.example.com/page.html").executeAsync(new WebRequest.Callback() {
public void onSuccess(String responseText) {
// do something
}
public void onError() {
// do something
}
});
String response = new WebRequest().get().to("http://www.example.com/page.html").executeSync();
// do something
Use any of the following variations (in combination) in order to adjust the instance's behaviour to your needs.
Instead of get()
, use either post()
, put()
or delete()
.
Example: auth("my_username", "my_password")
Example: asUserAgent("MyClient / 1.0")
Example: withTimeout(4000, 6000)
Example: withCharset("iso-8859-1")
askForGzip(true)
Example: addParam("my_key", "my_value")
Call executeSync()
instead of executeAsync()
and process the returned string.
Copyright (c) delight.im <info@delight.im>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You 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.
See the License for the specific language governing permissions and
limitations under the License.