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