RFR: 8331195: Improve com.sun.net.httpserver.HttpExchange usability [v4]
Daniel Fuchs
dfuchs at openjdk.org
Fri Jun 14 09:37:31 UTC 2024
On Fri, 14 Jun 2024 02:54:53 GMT, robert engels <duke at openjdk.org> wrote:
>> robert engels has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Merge remote-tracking branch 'robaho/HttpExchange-api-change' into HttpExchange-api-change
>>
>> # Conflicts:
>> # src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java
>> - update api changes based on comments
>
> Are we not going to do anything with this?
@robaho Thanks for restarting the discussion. IMO the two constants are OK, but I don't think the new proposed methods have gathered sufficient consensus to go in in this form yet.
Maybe we should brainstorm a bit more. For instance - we could rename the second parameter to sendResponseHeaders, and possibly rework the API documentation of that method.
public void sendResponseHeaders(int rCode, long lengthOrChunked);
then add
public void sendHeadersForChunkedResponse(int rcode) {
sendResponseHeaders(rCode, 0);
}
public void sendHeadersForFixedLengthResponse(int rcode, int responseLength) {
if (responseLength < 0) throw new IllegalArgumentException("negative length: " + responseLength);
sendResponseHeaders(rCode, responseLength == 0 ? -1 : responseLength);
}
```
and:
- add `@see` in `sendResponseHeaders` to link to the two new methods
- add an `@apiNote` to `sendResponseHeaders` to stress that using the other two methods is preferred.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18955#issuecomment-2167640579
More information about the net-dev
mailing list