Interface Submitter.Response
- Enclosing interface:
Submitter
public static interface Submitter.Response
Represents the response received from executing a request.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA supplier forInputStreamthat can throw anIOException. -
Method Summary
Modifier and TypeMethodDescriptionstatic Submitter.Responsecreate(int statusCode, Submitter.Response.InputStreamSupplier supplier, Exception exception) Creates a newSubmitter.Responseinstance.Gets the exception that occurred during execution, if any.Gets the response body input stream.intGets the HTTP response status code, or 0 / -1 if a client-side exception occurred.default booleanChecks if the request was accepted by the server.static byte[]readAll(InputStream stream) Reads the given stream completely.default StringReads the entire response body stream as a UTF-8 String.
-
Method Details
-
create
static Submitter.Response create(int statusCode, Submitter.Response.InputStreamSupplier supplier, Exception exception) Creates a newSubmitter.Responseinstance.The body of the created response is cached on the first read, so both
readString()andgetInputStream()may be called multiple times without losing data.- Parameters:
statusCode- the status codesupplier- the input stream supplier (can be null)exception- the exception (can be null)- Returns:
- the response instance
-
readAll
Reads the given stream completely.- Parameters:
stream- the stream to read- Returns:
- the read bytes
- Throws:
IOException- if an I/O error occurs
-
getStatusCode
int getStatusCode()Gets the HTTP response status code, or 0 / -1 if a client-side exception occurred.- Returns:
- the status code
-
getInputStream
Gets the response body input stream.- Returns:
- the input stream
- Throws:
IOException- if an I/O error occurs
-
getException
-
isSuccessful
default boolean isSuccessful()Checks if the request was accepted by the server.- Returns:
- true if the status code is in the 2xx range, false otherwise
-
readString
-