![Method count](https://img.shields.io/badge/Methods count-365-e91e63.svg)
Lightweight HTTP client using HttpURLConnection under the hood. The primary use case is for apps, libraries and SDKs which don't need/want all the features (and methods!) OkHttp provides.
It has the same limitations as HttpURLConnection like not supporting the PATCH method and not permitting request body in DELETE requests.
Add the library as a dependency to your build.gradle
to automatically download it from jcenter.
compile 'sexy.code:httpizza:0.3.0'
We also maintain a changelog.
HttPizza client = new HttPizza();
Request request = client.newRequest()
.url(url)
.get()
.build();
Response response = client.newCall(request).execute();
Request request = client.newRequest()
.url(url)
.post(RequestBody.create(MediaType.parse("text/plain; charset=utf-8"), "requestBody"))
.build();
Response response = client.newCall(request).execute();
Request request = client.newRequest()
.url(url)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onResponse(Response response) {
if (response.isSuccessful()) {
Timber.d("Body: %s", response.body().string());
} else {
Timber.d("Status code: %s", response.code());
}
}
@Override
public void onFailure(Throwable t) {
Timber.e(t.getMessage());
}
});
RequestBody formBody = new FormBody.Builder()
.add("search", "Airplane!")
.build();
Request request = client.newRequest()
.url(url)
.post(formBody)
.build();
Response response = client.newCall(request).execute();
HttPizza reuses parts of OkHttp and is largely based on lighthttp.
It also draws inspiration from OkHttp and Retrofit APIs.
Feedback and code contributions are very much welcome. Just make a pull request with a short description of your changes. By making contributions to this project you give permission for your code to be used under the same license.