Package com.github.fmjsjx.libnetty.http
Class HttpCommonUtil
java.lang.Object
com.github.fmjsjx.libnetty.http.HttpCommonUtil
Common utility class for HTTP.
- Since:
- 1.2
-
Method Summary
Modifier and TypeMethodDescriptionstatic final CharSequencebasicAuthentication(String user, String password) Returns the encoded basic authentication string.static final io.netty.util.AsciiStringcontentType(io.netty.util.AsciiString contentType) Returns thecontent-typeheader value withUTF-8character set parameter.static final io.netty.util.AsciiStringcontentType(io.netty.util.AsciiString contentType, Charset charset) Returns thecontent-typeheader value with the specifiedCharset.static final booleanisSuccess(io.netty.handler.codec.http.HttpResponse response) Returnstrueif the status is success,falseotherwise.static final booleanisSuccess(io.netty.handler.codec.http.HttpResponseStatus status) Returnstrueif the status is success,falseotherwise.static final booleanisSuccessStatus(int statusCode) Returnstrueif the status code is success,falseotherwise.static final StringremoteAddress(io.netty.channel.Channel channel, io.netty.handler.codec.http.HttpHeaders headers) Returns remote address from specifiedchannelandheaderson server side.
-
Method Details
-
remoteAddress
public static final String remoteAddress(io.netty.channel.Channel channel, io.netty.handler.codec.http.HttpHeaders headers) Returns remote address from specifiedchannelandheaderson server side.- Parameters:
channel- the channelheaders- the headers- Returns:
- the remote address of the client
-
contentType
public static final io.netty.util.AsciiString contentType(io.netty.util.AsciiString contentType) Returns thecontent-typeheader value withUTF-8character 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 thecontent-typeheader value with the specifiedCharset.- Parameters:
contentType- the content typecharset- theCharset- Returns:
- a
AsciiString
-
basicAuthentication
Returns the encoded basic authentication string.- Parameters:
user- the user namepassword- the password- Returns:
- the encoded basic authentication
-
isSuccessStatus
public static final boolean isSuccessStatus(int statusCode) Returnstrueif the status code is success,falseotherwise.- Parameters:
statusCode- the status code- Returns:
trueif the status code is success,falseotherwise
-
isSuccess
public static final boolean isSuccess(io.netty.handler.codec.http.HttpResponseStatus status) Returnstrueif the status is success,falseotherwise.- Parameters:
status- the status- Returns:
trueif the status is success,falseotherwise
-
isSuccess
public static final boolean isSuccess(io.netty.handler.codec.http.HttpResponse response) Returnstrueif the status is success,falseotherwise.- Parameters:
response- the response- Returns:
trueif the status is success,falseotherwise
-