类 HttpHelper
java.lang.Object
com.diboot.file.util.HttpHelper
HTTP请求相关工具类
- 版本:
- v2.0
- 作者:
- mazc@dibo.ltd
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private static TrustManager[]构建TrustManagerstatic String调用Http Get请求static String调用Http Post请求static okhttp3.ResponsecallPostResponse(String url, Map<String, String> formBody) 调用Http Post请求static voiddownloadFile(InputStream inputStream, long fileLength, String exportFileName, jakarta.servlet.http.HttpServletResponse response) static booleandownloadHttpFile(String fileUrl, String targetFilePath) HTTP下载文件static voiddownloadLocalFile(File localFile, String exportFileName, jakarta.servlet.http.HttpServletResponse response) 根据文件对象下载服务器文件static voiddownloadLocalFile(String localFilePath, String exportFileName, jakarta.servlet.http.HttpServletResponse response) 根据文件路径下载服务器本地文件private static StringexecuteCall(okhttp3.Call call, String url) 执行调用 返回结果static StringgetContextType(String fileName) 根据文件类型获取ContentTypestatic org.springframework.web.multipart.MultipartFilegetFileFromRequest(jakarta.servlet.http.HttpServletRequest request, String fileInputName) 获取请求中的单个文件数据static List<org.springframework.web.multipart.MultipartFile>getFilesFromRequest(jakarta.servlet.http.HttpServletRequest request, String fileInputName) 获取请求中的多个文件数据static voidwithHttps(okhttp3.OkHttpClient.Builder builder) 嵌入Https
-
字段详细资料
-
DEFAULT_CONTEXT_TYPE
默认contextType- 另请参阅:
-
EXT_CONTENT_TYPE_MAP
文件扩展名-ContentType的对应关系
-
-
构造器详细资料
-
HttpHelper
public HttpHelper()
-
-
方法详细资料
-
callGet
调用Http Get请求- 参数:
url-- 返回:
-
callPostResponse
调用Http Post请求- 参数:
url-- 返回:
-
callPost
调用Http Post请求- 参数:
url-- 返回:
-
withHttps
public static void withHttps(okhttp3.OkHttpClient.Builder builder) 嵌入Https- 参数:
builder-
-
buildTrustManagers
构建TrustManager- 返回:
-
executeCall
执行调用 返回结果- 参数:
call-url-- 返回:
-
downloadLocalFile
public static void downloadLocalFile(String localFilePath, String exportFileName, jakarta.servlet.http.HttpServletResponse response) throws Exception 根据文件路径下载服务器本地文件- 参数:
localFilePath- 本地文件路径exportFileName- 导出文件的文件名response-- 抛出:
Exception
-
downloadLocalFile
public static void downloadLocalFile(File localFile, String exportFileName, jakarta.servlet.http.HttpServletResponse response) throws Exception 根据文件对象下载服务器文件- 参数:
localFile- 本地文件对象exportFileName- 导出文件的文件名response-- 抛出:
Exception
-
downloadFile
public static void downloadFile(InputStream inputStream, long fileLength, String exportFileName, jakarta.servlet.http.HttpServletResponse response) throws Exception - 抛出:
Exception
-
downloadHttpFile
HTTP下载文件- 参数:
fileUrl-targetFilePath-- 返回:
-
getContextType
根据文件类型获取ContentType- 参数:
fileName-- 返回:
-
getFilesFromRequest
public static List<org.springframework.web.multipart.MultipartFile> getFilesFromRequest(jakarta.servlet.http.HttpServletRequest request, String fileInputName) 获取请求中的多个文件数据- 参数:
request-fileInputName-- 返回:
-
getFileFromRequest
public static org.springframework.web.multipart.MultipartFile getFileFromRequest(jakarta.servlet.http.HttpServletRequest request, String fileInputName) 获取请求中的单个文件数据- 参数:
request-fileInputName-- 返回:
-