Пример #1
0
  @Override
  public void setContentLength(int len) {
    // Protect from setting after committed as default handling
    // of a servlet HEAD request ALWAYS sets _content length, even
    // if the getHandling committed the response!
    if (isCommitted() || isIncluding()) return;

    long written = _out.getWritten();
    if (written > len)
      throw new IllegalArgumentException(
          "setContentLength(" + len + ") when already written " + written);

    _contentLength = len;
    _fields.putLongField(HttpHeader.CONTENT_LENGTH.toString(), len);

    if (_contentLength > 0) {
      try {
        closeIfAllContentWritten(written);
      } catch (IOException e) {
        throw new RuntimeIOException(e);
      }
    }
  }
Пример #2
0
 public long getContentCount() {
   return _out.getWritten();
 }