All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.jfunc.common.http.base.HttpTemplate Maven / Gradle / Ivy

Go to download

http客户端请求工具类,有多种实现:OKHttp3、ApacheHttpClient、HttpURLConnection,可以随意切换http实现

There is a newer version: 1.8.2.0
Show newest version
package top.jfunc.common.http.base;

import top.jfunc.common.http.Method;
import top.jfunc.common.http.smart.Request;
import top.jfunc.common.utils.ArrayListMultimap;
import top.jfunc.common.http.smart.SSLRequest;

import java.io.IOException;

/**
 * http请求的模板方法接口
 * @author xiongshiyan at 2018/6/19
 */
public interface HttpTemplate{
    /**
     * http请求的模板方法
     *
     * @param url URL
     * @param method 请求方法
     * @param contentType 请求体MIME类型
     * @param contentCallback 处理请求体的
     * @param headers headers
     * @param connectTimeout 连接超时时间
     * @param readTimeout 读取超时时间
     * @param resultCharset 结果字符集
     * @param includeHeaders 是否结果包含header
     * @param resultCallback 结果处理器
     * @param  处理的结果
     * @return 处理的结果
     * @throws IOException IOException
     */
     R template(String url, Method method, String contentType, ContentCallback contentCallback,
                   ArrayListMultimap headers, int connectTimeout, int readTimeout,
                   String resultCharset, boolean includeHeaders, ResultCallback resultCallback) throws IOException;

    /**
     * 使用Request来放请求数据
     * @param request 请求参数
     * @param method 请求方法
     * @see SSLRequest
     * @param contentCallback 内容处理器,处理文本或者文件上传
     * @param resultCallback 结果处理器
     * @throws IOException IOException
     * @return  R
     */
     R  template(Request request, Method method, ContentCallback contentCallback, ResultCallback resultCallback) throws IOException;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy