类 HttpHelper

java.lang.Object
com.diboot.file.util.HttpHelper

public class HttpHelper extends Object
HTTP请求相关工具类
版本:
v2.0
作者:
mazc@dibo.ltd
  • 字段详细资料

    • DEFAULT_CONTEXT_TYPE

      private static final String DEFAULT_CONTEXT_TYPE
      默认contextType
      另请参阅:
    • EXT_CONTENT_TYPE_MAP

      private static final Map<String,String> EXT_CONTENT_TYPE_MAP
      文件扩展名-ContentType的对应关系
  • 构造器详细资料

    • HttpHelper

      public HttpHelper()
  • 方法详细资料

    • callGet

      public static String callGet(String url, Map<String,String> headerMap)
      调用Http Get请求
      参数:
      url -
      返回:
    • callPostResponse

      public static okhttp3.Response callPostResponse(String url, Map<String,String> formBody)
      调用Http Post请求
      参数:
      url -
      返回:
    • callPost

      public static String callPost(String url, Map<String,String> formBody)
      调用Http Post请求
      参数:
      url -
      返回:
    • withHttps

      public static void withHttps(okhttp3.OkHttpClient.Builder builder)
      嵌入Https
      参数:
      builder -
    • buildTrustManagers

      private static TrustManager[] buildTrustManagers()
      构建TrustManager
      返回:
    • executeCall

      private static String executeCall(okhttp3.Call call, String url)
      执行调用 返回结果
      参数:
      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

      public static boolean downloadHttpFile(String fileUrl, String targetFilePath)
      HTTP下载文件
      参数:
      fileUrl -
      targetFilePath -
      返回:
    • getContextType

      public static String getContextType(String fileName)
      根据文件类型获取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 -
      返回: