java.lang.Object
dev.mccue.jdk.httpserver.ResponseLength
The length (in bytes)of a response body that will be sent through
an
HttpExchange.
This is either a known quantity, in which case the body written must match the number of bytes specified, or unknown, in which case the response is sent with a chunked encoding.
The need for this arises out of an idiosyncrasy in the HttpExchange.sendResponseHeaders(int, long)
method where 0 means that the size of a response is unknown and -1 means that there is no response
body to send.
-
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()static ResponseLengthknown(long responseLength) Construct aResponseLengthgiven a known response length that will be sent.toString()static ResponseLengthunknown()Construct aResponseLengthwhich represents an unknown number of bytes to be sent in a response.
-
Method Details
-
known
Construct aResponseLengthgiven a known response length that will be sent. Negative values are treated as if zero were provided.Note that unlike the
HttpExchange.sendResponseHeaders(int, long)method,0means a length of0, not an unknown length.- Parameters:
responseLength- The length of the response body to be sent.- Returns:
- An instance of
ResponseLength.
-
unknown
Construct aResponseLengthwhich represents an unknown number of bytes to be sent in a response.- Returns:
- An instance of
ResponseLength.
-
equals
-
hashCode
public int hashCode() -
toString
-