Skip to content

Latest commit

 

History

History
131 lines (104 loc) · 3.42 KB

README.md

File metadata and controls

131 lines (104 loc) · 3.42 KB

lighthttp

License Android Arsenal Download

Lightweitht HTTP client for Android.

Features

  • Simple HTTP client.
  • Depends on Android(HttpUrlConnection) only.
  • Execute asynchronously or can use with RxJava.
  • Convert request and response.

Usage

Get a url.

LightHttpClient httpClient = new LightHttpClient();
Request request = httpClient.newRequest()
    .url("https://api.github.com/users/satorufujiwara/repos")
    .get()
    .build();
Response<String> response = httpClient.newCall(request).execute();
String body = response.getBody();

Converter

Convert response to java object.

httpClient.setConverterProvider(new GsonConverterProvider());

Response<Repos> response = httpClient.newCall(request, Repos.class).execute();
Repos body = response.getBody();

Post json object.

httpClient.setConverterProvider(new GsonConverterProvider());

Item obj = new Item();
Request request = httpClient.newRequest()
    .url(url)
    .post(obj, Item.class)
    .build();

Executor

Execute asynchronously.

httpClient.newCall(request, Repos.class)
        .executeOn(AsyncExecutor.<Repos>provide())
        .executeAsync(new AsyncCallback<Repos>() {
            @Override
            public void onResult(Response<Repos> response, Throwable e) {
                
            }
        });

Use with RxJava.

httpClient.newCall(request, Repos.class)
            .executeOn(RxExecutor.<Repos>provide())
            .asObservable()
            .subscribeOn(Schedulers.io())
            .subscribe();

Gradle

dependencies {
    compile 'jp.satorufujiwara:lighthttp:0.1.1'
}

Converter

Gson

compile 'jp.satorufujiwara:lighthttp-gson:0.1.1'

Executor

Async

compile 'jp.satorufujiwara:lighthttp-async:0.1.1'

RxJava

compile 'jp.satorufujiwara:lighthttp-rx:0.1.1'

Milestone

  • Multipart request body.
  • Jackson converter.
  • Jsonic converter.
  • Sample app.
  • Testing.

Developed By

Satoru Fujiwara (satorufujiwara)

Other Projects

License

Copyright 2015 Satoru Fujiwara

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.