Exemplo n.º 1
0
  /**
   * Get the inputStream from the connection.
   *
   * <p>If the associated response has the Expect header set to 100 Continue, then accessing the
   * input stream indicates that the handler/servlet is ready for the request body and thus a 100
   * Continue response is sent.
   *
   * @return The input stream for this connection. The stream will be created if it does not already
   *     exist.
   */
  public ServletInputStream getInputStream() throws IOException {
    // If the client is expecting 100 CONTINUE, then send it now.
    if (_expect100Continue) {
      // is content missing?
      if (((HttpParser) _parser).getHeaderBuffer() == null
          || ((HttpParser) _parser).getHeaderBuffer().length() < 2) {
        if (_generator.isCommitted())
          throw new IllegalStateException("Committed before 100 Continues");

        ((HttpGenerator) _generator).send1xx(HttpStatus.CONTINUE_100);
      }
      _expect100Continue = false;
    }

    if (_in == null) _in = new HttpInput(HttpConnection.this);
    return _in;
  }