ws-http.java is a simple and independent HTTP Client library for girls

ws-http.java

I haven’t typed java code for a long time. Today, my sister asked me how to write http posts. The first thing that came to my mind was httpclient. , I remember that in the jdk there used to be sun.net.www.http.HttpClient with its own httpclient. It seems that it has been removed in jdk8. There is no way, the whole is simple, enough is enough.

Warehouse address:  https://github.com/toohamster/ws-http.java

Response httpResponse = new Request("http://www.yacebao.com")
        .getResource();

String responseBody = httpResponse.getBody();

// 
Response httpResponse = new Request("http://www.yacebao.com/")
        .addHeader("x-my-header", "foobar")
        .addQueryParameter("foo", "bar")
        .getResource();

String responseBody = httpResponse.getBody();

// Posts a simple JSON object to the server
Response httpResponse = new Request("http://www.yacebao.com/")
        .addHeader("x-my-header", "foobar")
        .addQueryParameter("foo", "bar")
        .setBody("{foo: 'bar'}")
        .postResource();

String responseBody = httpResponse.getBody();

HTTPS is not supported

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327042862&siteId=291194637