Class HttpHelper

java.lang.Object
cool.scx.http.HttpHelper

public class HttpHelper extends Object
HttpHelper
Version:
0.0.1
Author:
scx567888
  • Constructor Details

    • HttpHelper

      public HttpHelper()
  • Method Details

    • getRequestIP

      public static String getRequestIP(ScxHttpServerRequest request)

      获取访问者IP

      先从Header中获取X-Real-IP,如果不存在再从X-Forwarded-For获得第一个IP(用,分割), 如果还不存在则调用 HttpServerRequest.remoteAddress()

      Parameters:
      request - a
      Returns:
      IP
    • getDownloadContentDisposition

      public static String getDownloadContentDisposition(String downloadName)
      todo 这是一个 hack URLEncoder.encode 针对 ' ' (空格) 会编码为 '+' , 而这里我们需要的是编码为 %20
      Parameters:
      downloadName - a String object
      Returns:
      c
      See Also:
    • getMediaTypeByExtension

      public static MediaType getMediaTypeByExtension(String ext)
    • getMediaTypeByFileName

      public static MediaType getMediaTypeByFileName(String filename)