HttpRequest-Android

A chainable HttpRequest/Response library for Android.

License

License

MIT
GroupId

GroupId

com.github.danielgindi
ArtifactId

ArtifactId

httprequest
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

aar
Description

Description

HttpRequest-Android
A chainable HttpRequest/Response library for Android.
Project URL

Project URL

https://github.com/danielgindi/android-httprequest.git
Source Code Management

Source Code Management

https://github.com/danielgindi/android-httprequest.git

Download httprequest

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.danielgindi/httprequest/ -->
<dependency>
    <groupId>com.github.danielgindi</groupId>
    <artifactId>httprequest</artifactId>
    <version>1.2.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.danielgindi/httprequest/
implementation 'com.github.danielgindi:httprequest:1.2.0'
// https://jarcasting.com/artifacts/com.github.danielgindi/httprequest/
implementation ("com.github.danielgindi:httprequest:1.2.0")
'com.github.danielgindi:httprequest:aar:1.2.0'
<dependency org="com.github.danielgindi" name="httprequest" rev="1.2.0">
  <artifact name="httprequest" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.danielgindi', module='httprequest', version='1.2.0')
)
libraryDependencies += "com.github.danielgindi" % "httprequest" % "1.2.0"
[com.github.danielgindi/httprequest "1.2.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

HttpRequest

A Java based HttpRequest/Response library. This is currently only tested on the Android platform, but should work generally on any Java platform.

Why did I create this library? Mainly because I got tired of what was out there... Libraries that limit you in so many ways, or provide ugly API, or have bugs with encoding the multipart entities (like apache...). And one of the other reasons was that I just had to have a large request that does not fill up the device's memory, but prepares on disk and streams out to the connection.

I do not have the time yet for documentation, but it should be pretty self explanatory how to use this library. You have the HttpRequest class which, well, represents the HTTP request... You pass in parameters of any kind, headers, multi-parts, etc. and fire the connection. You can use the getResponse function synchronously on any thread you wish (except the UI thread!), or you can use the getResponseAsync which will internally use the AsyncTask mechanism.

Features:

  • Taking streams as request body or as multi-parts
  • Chunked encoding mode
  • Large requests will be created on disk first, to prevent wasting memory. (Content-Length must be calculated exactly, and so many libraries hold the whole request in memory and then calculate the length...)
  • Many helper functions to do stuff with the request and response.
  • Taking params with many types
  • Encoding Bitmap params
  • Adding files as parts without loading them to memory
  • Tracking progress of both request and response
  • Option to execute on a specific executor to prevent blocking the single Async thread
  • The HttpResponse class to wrap the response
  • HttpResponse will take care of caching the response to disk first if you work with getResponseAsync (or call prebuffer())
  • The connection is abortable at any stage of request of response
  • Most functions in HttpRequest are chainable

I strongly encourage getting involved in this project to make it better!

Have fun and a good luck with your projects!

Usage sample

TODO: :-)

Dependency

Download from Maven Central (.aar)

or

	dependencies {
    	compile 'com.github.danielgindi:httprequest:1.2.0'
	}

License

All the code here is under MIT license. Which means you could do virtually anything with the code. I will appreciate it very much if you keep an attribution where appropriate.

The MIT License (MIT)

Copyright (c) 2013 Daniel Cohen Gindi (danielgindi@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Versions

Version
1.2.0
1.1.1
1.1.0
1.0.0