类 HttpUtils

java.lang.Object
com.alibaba.nacos.common.http.HttpUtils

public final class HttpUtils extends Object
Http utils.
作者:
liaochuntao
  • 构造器详细资料

    • HttpUtils

      public HttpUtils()
  • 方法详细资料

    • initRequestHeader

      public static void initRequestHeader(org.apache.http.client.methods.HttpRequestBase requestBase, Header header)
      Init http header.
      参数:
      requestBase - requestBase HttpRequestBase
      header - header
    • initRequestEntity

      public static void initRequestEntity(org.apache.http.client.methods.HttpRequestBase requestBase, Object body, Header header) throws Exception
      Init http entity.
      参数:
      requestBase - requestBase HttpRequestBase
      body - body
      header - request header
      抛出:
      Exception - exception
    • initRequestFromEntity

      public static void initRequestFromEntity(org.apache.http.client.methods.HttpRequestBase requestBase, Map<String,​String> body, String charset) throws Exception
      Init request from entity map.
      参数:
      requestBase - requestBase HttpRequestBase
      body - body map
      charset - charset of entity
      抛出:
      Exception - exception
    • buildUrl

      public static String buildUrl(boolean isHttps, String serverAddr, String... subPaths)
      Build URL.
      参数:
      isHttps - whether is https
      serverAddr - server ip/address
      subPaths - api path
      返回:
      URL string
    • translateParameterMap

      public static Map<String,​String> translateParameterMap(Map<String,​String[]> parameterMap) throws Exception
      Translate parameter map.
      参数:
      parameterMap - parameter map
      返回:
      parameter map
      抛出:
      Exception - exception
    • encodingParams

      public static String encodingParams(Map<String,​String> params, String encoding) throws UnsupportedEncodingException
      Encoding parameters to url string.
      参数:
      params - parameters
      encoding - encoding charset
      返回:
      url string
      抛出:
      UnsupportedEncodingException - if encoding string is illegal
    • encodingParams

      public static String encodingParams(List<String> paramValues, String encoding) throws UnsupportedEncodingException
      Encoding KV list to url string.
      参数:
      paramValues - parameters
      encoding - encoding charset
      返回:
      url string
      抛出:
      UnsupportedEncodingException - if encoding string is illegal
    • decode

      public static String decode(String str, String encode) throws UnsupportedEncodingException
      抛出:
      UnsupportedEncodingException
    • buildUri

      public static URI buildUri(String url, Query query) throws URISyntaxException
      build URI By url and query.
      参数:
      url - url
      query - query param Query
      返回:
      URI
      抛出:
      URISyntaxException
    • isTimeoutException

      public static boolean isTimeoutException(Throwable throwable)
      HTTP request exception is a timeout exception.
      参数:
      throwable - http request throwable
      返回:
      boolean