Search in sources :

Example 1 with HttpRequestEntity

use of com.mendmix.common.http.HttpRequestEntity in project jeesuite-libs by vakinge.

the class HttpUtils method postJson.

public static HttpResponseEntity postJson(String url, String json, String charset) {
    String contentType = HttpClientProvider.CONTENT_TYPE_JSON_PREFIX + charset;
    HttpRequestEntity requestEntity = HttpRequestEntity.post(url).body(json).contentType(contentType);
    return execute(requestEntity);
}
Also used : HttpRequestEntity(com.mendmix.common.http.HttpRequestEntity)

Example 2 with HttpRequestEntity

use of com.mendmix.common.http.HttpRequestEntity in project jeesuite-libs by vakinge.

the class HttpUtils method uploadFile.

public static HttpResponseEntity uploadFile(String url, String fieldName, File file) {
    HttpRequestEntity requestEntity = HttpRequestEntity.post(url);
    requestEntity.fileParam(fieldName, file);
    return execute(requestEntity);
}
Also used : HttpRequestEntity(com.mendmix.common.http.HttpRequestEntity)

Example 3 with HttpRequestEntity

use of com.mendmix.common.http.HttpRequestEntity in project jeesuite-libs by vakinge.

the class HttpUtilsTest method main.

public static void main(String[] args) {
    ResourceUtils.add("mendmix.httputil.provider", "httpClient");
    HttpResponseEntity entity;
    entity = HttpUtils.get("http://www.kuaidi100.com/query?type=yuantong&postid=11111111111");
    System.out.println(entity);
    String json = "{\"example\":{\"env\":\"dev\"},\"pageNo\":1,\"pageSize\":10}";
    entity = HttpUtils.postJson("http://openapi.mytest.com/api/commonlog/custom_log/list?_logType=mq_produce_logs", json);
    System.out.println(entity);
    HttpRequestEntity requestEntity = HttpRequestEntity.get("http://").basicAuth("admin", "123456");
    entity = HttpUtils.execute(requestEntity);
    System.out.println(entity);
}
Also used : HttpResponseEntity(com.mendmix.common.http.HttpResponseEntity) HttpRequestEntity(com.mendmix.common.http.HttpRequestEntity)

Aggregations

HttpRequestEntity (com.mendmix.common.http.HttpRequestEntity)3 HttpResponseEntity (com.mendmix.common.http.HttpResponseEntity)1