All Projects → satorufujiwara → lighthttp

satorufujiwara / lighthttp

Licence: Apache-2.0 license
Lightweitht HTTP client for Android

Programming Languages

java
68154 projects - #9 most used programming language

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].