Http Client API

Posted by Bruce Tsai

說明

簡便使用的 http client。

範例

String html = UrlHttpClient.connect("http://www.somewhere.com/product")
        .data("id", "123")
        .get();
String html = UrlHttpClient.connect("http://www.somewhere.com/product")
        .data("id", "123")
        .data("type", "bed")
        .header("UID", "iadsfjadihfajsdf;lkj")
        .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36")
        .cookie("track", "628372")
        .post();
IHttpClientResponse response = UrlHttpClient.connect("http://www.somewhere.com/pdf")
        .data("id", "123")
        .method(HttpMethod.POST)
        .execute();

if(response.statusCode() == 200){
    byte[] bytes = response.bodyAsBytes();

    // more code here
}

results matching ""

    No results matching ""