Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mntone/httpclient
Modern HttpClient for Java 6+. It just likes .NET HttpClient.
https://github.com/mntone/httpclient
Last synced: 8 days ago
JSON representation
Modern HttpClient for Java 6+. It just likes .NET HttpClient.
- Host: GitHub
- URL: https://github.com/mntone/httpclient
- Owner: mntone
- License: mit
- Created: 2015-10-24T08:33:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-04T07:41:56.000Z (about 9 years ago)
- Last Synced: 2023-03-24T01:57:40.680Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 289 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Modern HttpClient (Java 6+)
[![License](https://img.shields.io/github/license/mntone/HttpClient.svg?style=flat-square)](https://github.com/mntone/HttpClient/blob/master/LICENSE.txt)
It’s Modern HttpClient for JVM. It just likes .NET HttpClient.
## Requirement
- [jsr166e](http://g.oswego.edu/dl/concurrency-interest/)
- [Apache Commons Codec](http://commons.apache.org/proper/commons-codec/)## Usage
### Get content as `String`
It’s very simple.
```java
final HttpClient client = new HttpClient();
try
{
final String responseText = client.getStringAsync("http://mntone.minibird.jp/").get();
System.out.print(responseText);
}
catch (final Exception e) { }
```### Post content
```java
final HashMap content = new HashMap();
content.put("test1", "test");
content.put("test2", "test");final HttpClient client = new HttpClient();
HttpResponseMessage res = null;
try
{
res = client.postAsync("http://httpbin.org/post", new FormUrlEncodedContent(content)).get();
final String resText = res.getContent().readAsStringAsync().get();
System.out.print(resText);
}
catch (final Exception e) { }
finally
{
if (res != null)
{
try
{
res.close();
}
catch (final IOException e) { }
finally
{
res = null;
}
}
}
```## LICENSE
[MIT License](https://github.com/mntone/HttpClient/blob/master/LICENSE.txt)
## Contributing
1. Fork it.
2. Create your feature branch. (`git checkout -b NEW_FEATURE_BRANCH_NAME`) ← **important!**
3. Commit, push, and pull request!## Author
- mntone
GitHub: https://github.com/mntone
Twitter: https://twitter.com/mntone (posted in Japanese; however, english is ok)