Class HttpCommonUtil

java.lang.Object
com.github.fmjsjx.libnetty.http.HttpCommonUtil

public final class HttpCommonUtil extends Object
Common utility class for HTTP.
Since:
1.2
  • Method Summary

    Modifier and Type
    Method
    Description
    static final CharSequence
    Returns the encoded basic authentication string.
    static final io.netty.util.AsciiString
    contentType(io.netty.util.AsciiString contentType)
    Returns the content-type header value with UTF-8 character set parameter.
    static final io.netty.util.AsciiString
    contentType(io.netty.util.AsciiString contentType, Charset charset)
    Returns the content-type header value with the specified Charset.
    static final boolean
    isSuccess(io.netty.handler.codec.http.HttpResponse response)
    Returns true if the status is success, false otherwise.
    static final boolean
    isSuccess(io.netty.handler.codec.http.HttpResponseStatus status)
    Returns true if the status is success, false otherwise.
    static final boolean
    isSuccessStatus(int statusCode)
    Returns true if the status code is success, false otherwise.
    static final String
    remoteAddress(io.netty.channel.Channel channel, io.netty.handler.codec.http.HttpHeaders headers)
    Returns remote address from specified channel and headers on server side.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • remoteAddress

      public static final String remoteAddress(io.netty.channel.Channel channel, io.netty.handler.codec.http.HttpHeaders headers)
      Returns remote address from specified channel and headers on server side.
      Parameters:
      channel - the channel
      headers - the headers
      Returns:
      the remote address of the client
    • contentType

      public static final io.netty.util.AsciiString contentType(io.netty.util.AsciiString contentType)
      Returns the content-type header value with UTF-8 character set parameter.
      Parameters:
      contentType - the content type
      Returns:
      a AsciiString
    • contentType

      public static final io.netty.util.AsciiString contentType(io.netty.util.AsciiString contentType, Charset charset)
      Returns the content-type header value with the specified Charset.
      Parameters:
      contentType - the content type
      charset - the Charset
      Returns:
      a AsciiString
    • basicAuthentication

      public static final CharSequence basicAuthentication(String user, String password)
      Returns the encoded basic authentication string.
      Parameters:
      user - the user name
      password - the password
      Returns:
      the encoded basic authentication
    • isSuccessStatus

      public static final boolean isSuccessStatus(int statusCode)
      Returns true if the status code is success, false otherwise.
      Parameters:
      statusCode - the status code
      Returns:
      true if the status code is success, false otherwise
    • isSuccess

      public static final boolean isSuccess(io.netty.handler.codec.http.HttpResponseStatus status)
      Returns true if the status is success, false otherwise.
      Parameters:
      status - the status
      Returns:
      true if the status is success, false otherwise
    • isSuccess

      public static final boolean isSuccess(io.netty.handler.codec.http.HttpResponse response)
      Returns true if the status is success, false otherwise.
      Parameters:
      response - the response
      Returns:
      true if the status is success, false otherwise