Package top.focess.qq.api.util.network
Class HttpResponse
- java.lang.Object
-
- top.focess.qq.api.util.network.HttpResponse
-
public class HttpResponse extends Object
This class is used to define a response to a http-request
-
-
Field Summary
Fields Modifier and Type Field Description static intEXCEPTIONException thrown error codestatic intUNKNOWN_REQUESTUnknown request type error code
-
Constructor Summary
Constructors Constructor Description HttpResponse(int code, okhttp3.Headers headers, String value)Initialize a HttpResponse without exceptionsHttpResponse(Exception e)Initialize an exception thrown HttpResponse with e
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull JSONgetAsJSON()Get the values as JSON instanceintgetCode()@Nullable ExceptiongetException()@Nullable okhttp3.HeadersgetHeaders()@Nullable StringgetResponse()booleanisError()Indicate this is an exception thrown HttpResponsestatic HttpResponseofNull()
-
-
-
Field Detail
-
UNKNOWN_REQUEST
public static final int UNKNOWN_REQUEST
Unknown request type error code- See Also:
- Constant Field Values
-
EXCEPTION
public static final int EXCEPTION
Exception thrown error code- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpResponse
public HttpResponse(Exception e)
Initialize an exception thrown HttpResponse with e- Parameters:
e- the thrown exception in this http-request processing
-
HttpResponse
public HttpResponse(int code, okhttp3.Headers headers, String value)Initialize a HttpResponse without exceptions- Parameters:
code- the response codeheaders- the response headervalue- the response data
-
-
Method Detail
-
isError
public boolean isError()
Indicate this is an exception thrown HttpResponse- Returns:
- true if this is an exception thrown HttpResponse, false otherwise
-
ofNull
public static HttpResponse ofNull()
-
getException
@Nullable public @Nullable Exception getException()
-
getCode
public int getCode()
-
getAsJSON
@NotNull public @NotNull JSON getAsJSON()
Get the values as JSON instance- Returns:
- JSON instance of this response data
-
getResponse
@Nullable public @Nullable String getResponse()
-
getHeaders
@Nullable public @Nullable okhttp3.Headers getHeaders()
-
-