Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8331195

Improve com.sun.net.httpserver.HttpExchange usability

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      HttpExchange.sendResponseHeaders takes two parameters - the int responseCode and a long parameter which specifies the content length.

      The content-length parameter is counter intuitive where the value 0 means use chunked encoding, whereas the value -1 (or any value < 0) means no content.

      A simple improvement could be to add two symbolic constant values to HttpExchange such as:

      public static final long NO_CONTENT = -1L;

      and

      public static final long CHUNKED_CONTENT = 0L;

      A convenience method for sending no content could be added such as:


      public final void sendResponseHeadersNoContent(int code)

      An apiNote can be added to the existing sendResponseHeaders method referring to the constants and the new method

            michaelm Michael McMahon
            michaelm Michael McMahon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: