Example #1
0
    @Override
    protected SelectChannelEndPoint newEndPoint(
        SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException {
      // We're connected, cancel the connect timeout
      Timeout.Task connectTimeout = _connectingChannels.remove(channel);
      if (connectTimeout != null) connectTimeout.cancel();
      if (LOG.isDebugEnabled())
        LOG.debug("Channels with connection pending: {}", _connectingChannels.size());

      // key should have destination at this point (will be replaced by endpoint after this call)
      HttpDestination dest = (HttpDestination) key.attachment();

      SelectChannelEndPoint scep =
          new SelectChannelEndPoint(channel, selectSet, key, (int) _httpClient.getIdleTimeout());
      AsyncEndPoint ep = scep;

      if (dest.isSecure()) {
        LOG.debug("secure to {}, proxied={}", channel, dest.isProxied());
        ep = new UpgradableEndPoint(ep, newSslEngine(channel));
      }

      AsyncConnection connection =
          selectSet.getManager().newConnection(channel, ep, key.attachment());
      ep.setConnection(connection);

      AbstractHttpConnection httpConnection = (AbstractHttpConnection) connection;
      httpConnection.setDestination(dest);

      if (dest.isSecure() && !dest.isProxied()) ((UpgradableEndPoint) ep).upgrade();

      dest.onNewConnection(httpConnection);

      return scep;
    }
Example #2
0
    public void upgrade() {
      AsyncHttpConnection connection = (AsyncHttpConnection) _endp.getConnection();

      SslConnection sslConnection = new SslConnection(_engine, _endp);
      _endp.setConnection(sslConnection);

      _endp = sslConnection.getSslEndPoint();
      sslConnection.getSslEndPoint().setConnection(connection);

      LOG.debug("upgrade {} to {} for {}", this, sslConnection, connection);
    }
 /*
  * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#content(int, org.eclipse.io.Buffer)
  */
 @Override
 public void content(Buffer ref) throws IOException {
   if (_endp instanceof AsyncEndPoint) ((AsyncEndPoint) _endp).scheduleIdle();
   if (_delayedHandling) {
     _delayedHandling = false;
     handleRequest();
   }
 }
    /*
     * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#headerComplete()
     */
    @Override
    public void headerComplete() throws IOException {
      if (_endp instanceof AsyncEndPoint) ((AsyncEndPoint) _endp).scheduleIdle();
      _requests++;
      _generator.setVersion(_version);
      switch (_version) {
        case HttpVersions.HTTP_0_9_ORDINAL:
          break;
        case HttpVersions.HTTP_1_0_ORDINAL:
          _generator.setHead(_head);

          if (_server.getSendDateHeader()) _generator.setDate(_request.getTimeStampBuffer());

          break;
        case HttpVersions.HTTP_1_1_ORDINAL:
          _generator.setHead(_head);

          if (_server.getSendDateHeader()) _generator.setDate(_request.getTimeStampBuffer());

          if (!_host) {
            _generator.setResponse(HttpStatus.BAD_REQUEST_400, null);
            _responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE_BUFFER);
            _generator.completeHeader(_responseFields, true);
            _generator.complete();
            return;
          }

          if (_expect) {
            _generator.setResponse(HttpStatus.EXPECTATION_FAILED_417, null);
            _responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE_BUFFER);
            _generator.completeHeader(_responseFields, true);
            _generator.complete();
            return;
          }

          break;
        default:
      }

      if (_charset != null) _request.setCharacterEncodingUnchecked(_charset);

      // Either handle now or wait for first content
      if ((((HttpParser) _parser).getContentLength() <= 0 && !((HttpParser) _parser).isChunking())
          || _expect100Continue) handleRequest();
      else _delayedHandling = true;
    }
Example #5
0
 public boolean isCheckForIdle() {
   return _endp.isCheckForIdle();
 }
Example #6
0
 public void onIdleExpired(long idleForMs) {
   _endp.onIdleExpired(idleForMs);
 }
Example #7
0
 public int getMaxIdleTime() {
   return _endp.getMaxIdleTime();
 }
Example #8
0
 public Object getTransport() {
   return _endp.getTransport();
 }
Example #9
0
 public boolean blockWritable(long millisecs) throws IOException {
   return _endp.blockWritable(millisecs);
 }
Example #10
0
 public int getRemotePort() {
   return _endp.getRemotePort();
 }
Example #11
0
 public boolean hasProgressed() {
   return _endp.hasProgressed();
 }
Example #12
0
 public boolean isWritable() {
   return _endp.isWritable();
 }
Example #13
0
 public int fill(Buffer buffer) throws IOException {
   return _endp.fill(buffer);
 }
Example #14
0
 public void close() throws IOException {
   _endp.close();
 }
Example #15
0
 public boolean isInputShutdown() {
   return _endp.isInputShutdown();
 }
Example #16
0
 public String getRemoteAddr() {
   return _endp.getRemoteAddr();
 }
Example #17
0
 public String getRemoteHost() {
   return _endp.getRemoteHost();
 }
Example #18
0
 public int flush(Buffer buffer) throws IOException {
   return _endp.flush(buffer);
 }
Example #19
0
 public boolean isBlocking() {
   return _endp.isBlocking();
 }
Example #20
0
 public void scheduleTimeout(Task task, long timeoutMs) {
   _endp.scheduleTimeout(task, timeoutMs);
 }
Example #21
0
 public boolean isOpen() {
   return _endp.isOpen();
 }
Example #22
0
 public void cancelTimeout(Task task) {
   _endp.cancelTimeout(task);
 }
Example #23
0
 public void flush() throws IOException {
   _endp.flush();
 }
Example #24
0
 public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException {
   return _endp.flush(header, buffer, trailer);
 }
Example #25
0
 public void setMaxIdleTime(int timeMs) throws IOException {
   _endp.setMaxIdleTime(timeMs);
 }
Example #26
0
 public String getLocalAddr() {
   return _endp.getLocalAddr();
 }
Example #27
0
 public void setCheckForIdle(boolean check) {
   _endp.setCheckForIdle(check);
 }
Example #28
0
 public String getLocalHost() {
   return _endp.getLocalHost();
 }
Example #29
0
 public String toString() {
   return "Upgradable:" + _endp.toString();
 }
Example #30
0
 public int getLocalPort() {
   return _endp.getLocalPort();
 }