Exemple #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;
    }
Exemple #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;
    }
Exemple #5
0
 public boolean isCheckForIdle() {
   return _endp.isCheckForIdle();
 }
Exemple #6
0
 public void onIdleExpired(long idleForMs) {
   _endp.onIdleExpired(idleForMs);
 }
Exemple #7
0
 public int getMaxIdleTime() {
   return _endp.getMaxIdleTime();
 }
Exemple #8
0
 public Object getTransport() {
   return _endp.getTransport();
 }
Exemple #9
0
 public boolean blockWritable(long millisecs) throws IOException {
   return _endp.blockWritable(millisecs);
 }
Exemple #10
0
 public int getRemotePort() {
   return _endp.getRemotePort();
 }
Exemple #11
0
 public boolean hasProgressed() {
   return _endp.hasProgressed();
 }
Exemple #12
0
 public boolean isWritable() {
   return _endp.isWritable();
 }
Exemple #13
0
 public int fill(Buffer buffer) throws IOException {
   return _endp.fill(buffer);
 }
Exemple #14
0
 public void close() throws IOException {
   _endp.close();
 }
Exemple #15
0
 public boolean isInputShutdown() {
   return _endp.isInputShutdown();
 }
Exemple #16
0
 public String getRemoteAddr() {
   return _endp.getRemoteAddr();
 }
Exemple #17
0
 public String getRemoteHost() {
   return _endp.getRemoteHost();
 }
Exemple #18
0
 public int flush(Buffer buffer) throws IOException {
   return _endp.flush(buffer);
 }
Exemple #19
0
 public boolean isBlocking() {
   return _endp.isBlocking();
 }
Exemple #20
0
 public void scheduleTimeout(Task task, long timeoutMs) {
   _endp.scheduleTimeout(task, timeoutMs);
 }
Exemple #21
0
 public boolean isOpen() {
   return _endp.isOpen();
 }
Exemple #22
0
 public void cancelTimeout(Task task) {
   _endp.cancelTimeout(task);
 }
Exemple #23
0
 public void flush() throws IOException {
   _endp.flush();
 }
Exemple #24
0
 public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException {
   return _endp.flush(header, buffer, trailer);
 }
Exemple #25
0
 public void setMaxIdleTime(int timeMs) throws IOException {
   _endp.setMaxIdleTime(timeMs);
 }
Exemple #26
0
 public String getLocalAddr() {
   return _endp.getLocalAddr();
 }
Exemple #27
0
 public void setCheckForIdle(boolean check) {
   _endp.setCheckForIdle(check);
 }
Exemple #28
0
 public String getLocalHost() {
   return _endp.getLocalHost();
 }
Exemple #29
0
 public String toString() {
   return "Upgradable:" + _endp.toString();
 }
Exemple #30
0
 public int getLocalPort() {
   return _endp.getLocalPort();
 }