Giter Site home page Giter Site logo

http-kit's Introduction

HTTP Kit

Contains:

  • Requests (a very basic Java HTTP client for humans, inspired by Python's Requests library.)
  • Responses (a very basic Java HTTP server for http clients testing and debugging)

Library is not stable yet, please, use with care

Maven dependency

<dependency>
    <groupId>com.andreidemus.http-kit</groupId>
    <artifactId>http-kit</artifactId>
    <version>0.0.1</version>
</dependency>

Requests

Usage

Example 1

final String responseBody = Requests.get("https://api.github.com/zen").text();
System.out.println(responseBody);
> Speak like a human.

Example 2

final Request request = new Request("http://httpbin.org").path("post")
                                                         .header("Content-Type", "application/json")
                                                         .pathParam("a", 5)
                                                         .body("{\"x\":10}");
final Response response = Requests.post(request);
System.out.println(response);
> Status: 200
Reason: OK
Headers:
{
  X-Processed-Time : [0.000765085220337]
  Server : [meinheld/0.6.1]
  Access-Control-Allow-Origin : [*]
  Access-Control-Allow-Credentials : [true]
  Connection : [keep-alive]
  Content-Length : [444]
  Date : [Thu, 07 Sep 2017 19:05:42 GMT]
  Content-Type : [application/json]
  X-Powered-By : [Flask]
  Via : [1.1 vegur]
}
Body:
{
  "args": {
    "a": "5"
  }, 
  "data": "{\"x\":10}", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2", 
    "Connection": "close", 
    "Content-Length": "8", 
    "Content-Type": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "Java/1.8.0_112"
  }, 
  "json": {
    "x": 10
  }, 
  "origin": "178.210.135.192", 
  "url": "http://httpbin.org/post?a=5"
}

http-kit's People

Contributors

andriidemus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.