Skip to content

Simple Http Library to make request and access the response.

License

Notifications You must be signed in to change notification settings

amitbhoraniya/http-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Dependency Status

Http Request

Simple Http Library to make request and access the response.

  1. Create a Request Object
  2. Create instance of HttpClient using request instance.
  3. Send Request

Send GET Request

Request request = new Request("http://httpbin.org/get");
HttpClient client = new HttpClient(request);
Response response = client.execute();

Pass Query Parameters

Request request = new Request("http://httpbin.org/get");
request.args("search","amit").args("type","people");

//will convert to http://httpbin.org/get?search=amit&type=people

Response response = new HttpClient(request).execute();

Send POST Request

Request request = new Request("http://httpbin.org/post", RequestMethod.POST);
Response response = new HttpClient(request).execute();

Post Request with Form Data

Request request = new Request("http://httpbin.org/post", RequestMethod.POST);

//Form-Data
request.form("key1", "value1").form("key2", "value2");

Response response = new HttpClient(request);.execute();

GZip Compression

Request request = new Request("http://httpbin.org/gzip");
request.acceptGzipEncoding().uncompress(true);
Response response = new HttpClient(request).execute();

Trust Certificates

Request request = new Request("https://httpbin.org/get");
//To trust all certificate
request.trustCert(true);
Response response = new HttpClient(request).execute();

About

Simple Http Library to make request and access the response.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages