Exemplo n.º 1
0
 /**
  * Implemented for bug 79865
  *
  * <p>Disable the Jetty timeout for for this request.
  *
  * <p>By default (and our normal configuration) Jetty has a 60 second idle timeout (10 if the
  * server is busy) for connection endpoints. There's another task that keeps track of what
  * connections have timeouts and periodically works over a queue and closes endpoints that have
  * been timed out. This plays havoc with DAV over slow connections and whenever we have a long
  * pause.
  *
  * @throws IOException
  */
 protected void disableJettyTimeout() throws IOException {
   // millisecond value.  0 or negative means infinite.
   long maxIdleTime = LC.zimbra_dav_max_idle_time_ms.intValue();
   EndPoint endPoint = HttpConnection.getCurrentConnection().getEndPoint();
   if (endPoint instanceof SelectChannelEndPoint) {
     SelectChannelEndPoint scEndPoint = (SelectChannelEndPoint) endPoint;
     scEndPoint.setIdleTimeout(maxIdleTime);
   }
 }
Exemplo n.º 2
0
  @Override
  protected void blockForContent() throws IOException {
    while (true) {
      _httpConnection.fillInterested(_readBlocker);
      LOG.debug("{} block readable on {}", this, _readBlocker);
      _readBlocker.block();

      Object content = getNextContent();
      if (content != null || isFinished()) break;
    }
  }
Exemplo n.º 3
0
  @Override
  protected ByteBuffer nextContent() throws IOException {
    // If we have some content available, return it
    if (BufferUtil.hasContent(_content)) return _content;

    // No - then we are going to need to parse some more content
    _content = null;
    ByteBuffer requestBuffer = _httpConnection.getRequestBuffer();

    while (!_httpConnection.getParser().isComplete()) {
      // Can the parser progress (even with an empty buffer)
      _httpConnection
          .getParser()
          .parseNext(requestBuffer == null ? BufferUtil.EMPTY_BUFFER : requestBuffer);

      // If we got some content, that will do for now!
      if (BufferUtil.hasContent(_content)) return _content;

      // No, we can we try reading some content?
      if (BufferUtil.isEmpty(requestBuffer) && _httpConnection.getEndPoint().isInputShutdown()) {
        _httpConnection.getParser().atEOF();
        continue;
      }

      // OK lets read some data
      int filled = _httpConnection.getEndPoint().fill(requestBuffer);
      if (LOG.isDebugEnabled()) // Avoid boxing of variable 'filled'
      LOG.debug("{} filled {}", this, filled);
      if (filled <= 0) {
        if (filled < 0) {
          _httpConnection.getParser().atEOF();
          continue;
        }
        return null;
      }
    }

    return null;
  }
Exemplo n.º 4
0
 @Override
 public void failed(Throwable x) {
   super.failed(x);
   _httpConnection.getHttpChannel().getState().onReadPossible();
 }
Exemplo n.º 5
0
 @Override
 public void succeeded() {
   _httpConnection.getHttpChannel().getState().onReadPossible();
 }
Exemplo n.º 6
0
 @Override
 protected void unready() {
   _httpConnection.fillInterested(this);
 }