src/share/classes/com/sun/net/httpserver/HttpExchange.java

Print this page




  48  * <li>{@link #getResponseHeaders()} to set any response headers, except content-length
  49  * <li>{@link #sendResponseHeaders(int,long)} to send the response headers. Must be called before
  50  * next step.
  51  * <li>{@link #getResponseBody()} to get a {@link java.io.OutputStream} to send the response body.
  52  *      When the response body has been written, the stream must be closed to terminate the exchange.
  53  * </ol>
  54  * <b>Terminating exchanges</b>
  55  * <br>
  56  * Exchanges are terminated when both the request InputStream and response OutputStream are closed.
  57  * Closing the OutputStream, implicitly closes the InputStream (if it is not already closed).
  58  * However, it is recommended
  59  * to consume all the data from the InputStream before closing it.
  60  * The convenience method {@link #close()} does all of these tasks.
  61  * Closing an exchange without consuming all of the request body is not an error
  62  * but may make the underlying TCP connection unusable for following exchanges.
  63  * The effect of failing to terminate an exchange is undefined, but will typically
  64  * result in resources failing to be freed/reused.
  65  * @since 1.6
  66  */
  67 

  68 public abstract class HttpExchange {
  69 
  70     protected HttpExchange () {
  71     }
  72 
  73     /**
  74      * Returns an immutable Map containing the HTTP headers that were
  75      * included with this request. The keys in this Map will be the header
  76      * names, while the values will be a List of Strings containing each value
  77      * that was included (either for a header that was listed several times,
  78      * or one that accepts a comma-delimited list of values on a single line).
  79      * In either of these cases, the values for the header name will be
  80      * presented in the order that they were included in the request.
  81      * <p>
  82      * The keys in Map are case-insensitive.
  83      * @return a read-only Map which can be used to access request headers
  84      */
  85     public abstract Headers getRequestHeaders () ;
  86 
  87     /**




  48  * <li>{@link #getResponseHeaders()} to set any response headers, except content-length
  49  * <li>{@link #sendResponseHeaders(int,long)} to send the response headers. Must be called before
  50  * next step.
  51  * <li>{@link #getResponseBody()} to get a {@link java.io.OutputStream} to send the response body.
  52  *      When the response body has been written, the stream must be closed to terminate the exchange.
  53  * </ol>
  54  * <b>Terminating exchanges</b>
  55  * <br>
  56  * Exchanges are terminated when both the request InputStream and response OutputStream are closed.
  57  * Closing the OutputStream, implicitly closes the InputStream (if it is not already closed).
  58  * However, it is recommended
  59  * to consume all the data from the InputStream before closing it.
  60  * The convenience method {@link #close()} does all of these tasks.
  61  * Closing an exchange without consuming all of the request body is not an error
  62  * but may make the underlying TCP connection unusable for following exchanges.
  63  * The effect of failing to terminate an exchange is undefined, but will typically
  64  * result in resources failing to be freed/reused.
  65  * @since 1.6
  66  */
  67 
  68 @jdk.Supported
  69 public abstract class HttpExchange {
  70 
  71     protected HttpExchange () {
  72     }
  73 
  74     /**
  75      * Returns an immutable Map containing the HTTP headers that were
  76      * included with this request. The keys in this Map will be the header
  77      * names, while the values will be a List of Strings containing each value
  78      * that was included (either for a header that was listed several times,
  79      * or one that accepts a comma-delimited list of values on a single line).
  80      * In either of these cases, the values for the header name will be
  81      * presented in the order that they were included in the request.
  82      * <p>
  83      * The keys in Map are case-insensitive.
  84      * @return a read-only Map which can be used to access request headers
  85      */
  86     public abstract Headers getRequestHeaders () ;
  87 
  88     /**