FileServerHandler::discardRequestBody calls InputStream::readAllBytes to read and discard all the request body bytes off the network.
Since we're going to discard the bytes then we don't really need to accumulate them so using readAllBytes for that seems wasteful.
The InputStream this is called on is one of the specific InputStream sub classes provided by the server implementation, which deal with clear text vs TLS, chunked vs fixed length etc... At some point they eventually delegate to the socket input stream.
Possibly InputStream::skip(Integer.MAX_VALUE) could be used instead, after double checking that it's been correctly overridden by the subclasses if needed, or maybe a loop that repeatedly read 1024 bytes until EOF is reached.
https://github.com/openjdk/jdk/blob/377138c7b58d0dd6f11ef4c4fa5598fd836f39df/src/jdk.httpserver/share/classes/sun/net/httpserver/simpleserver/FileServerHandler.java#L160-L164
Since we're going to discard the bytes then we don't really need to accumulate them so using readAllBytes for that seems wasteful.
The InputStream this is called on is one of the specific InputStream sub classes provided by the server implementation, which deal with clear text vs TLS, chunked vs fixed length etc... At some point they eventually delegate to the socket input stream.
Possibly InputStream::skip(Integer.MAX_VALUE) could be used instead, after double checking that it's been correctly overridden by the subclasses if needed, or maybe a loop that repeatedly read 1024 bytes until EOF is reached.
https://github.com/openjdk/jdk/blob/377138c7b58d0dd6f11ef4c4fa5598fd836f39df/src/jdk.httpserver/share/classes/sun/net/httpserver/simpleserver/FileServerHandler.java#L160-L164