use of com.ning.http.client.AsyncHttpClient.BoundRequestBuilder in project new-cloud by xie-summer.
the class AsyncHttpUtils method postUrlAsString.
/**
* 通过POST方法请求url
*
* @param url
* @param params
*/
public static void postUrlAsString(String url, Map<String, String> params, int reqTimeout, HttpResultCallback callback) {
try {
BoundRequestBuilder rb = getAsyncHttpClient(reqTimeout).preparePost(url);
rb.setHeader("Accept-Encoding", "gzip,deflate");
rb.setBodyEncoding("utf-8");
setPostParams(params, rb);
rb.execute(new AsynchHandler(callback));
} catch (IOException e) {
DB_LOGGER.error(e, 30);
}
}
use of com.ning.http.client.AsyncHttpClient.BoundRequestBuilder in project new-cloud by xie-summer.
the class AsyncHttpUtils method uploadFile.
public static void uploadFile(String url, Map<String, String> params, byte[] bytes, String inputName, String fileName, HttpResultCallback callback) {
try {
BoundRequestBuilder rb = getDefault().preparePost(url);
setPostParams(params, rb);
ByteArrayPart part = new ByteArrayPart(inputName, fileName, bytes, null, "utf-8");
rb.addBodyPart(part);
rb.execute(new AsynchHandler(callback));
} catch (IOException e) {
DB_LOGGER.error(e, 30);
}
}
Aggregations