Package org.eclipse.jetty.io

Examples of org.eclipse.jetty.io.EndPoint


                            this, protocol, ConnectionFactory.class.getName());
                    close();
                }
                else
                {
                    EndPoint endPoint = getEndPoint();
                    Connection oldConnection = endPoint.getConnection();
                    Connection newConnection = connectionFactory.newConnection(connector, endPoint);
                    LOG.debug("{} switching from {} to {}", this, oldConnection, newConnection);
                    oldConnection.onClose();
                    endPoint.setConnection(newConnection);
                    getEndPoint().getConnection().onOpen();
                }
            }
        }
        else if (filled < 0)
View Full Code Here


        disconnect(false);
    }

    private void disconnect(boolean onlyOutput)
    {
        EndPoint endPoint = getEndPoint();
        // We need to gently close first, to allow
        // SSL close alerts to be sent by Jetty
        LOG.debug("Shutting down output {}",endPoint);
        endPoint.shutdownOutput();
        if (!onlyOutput)
        {
            LOG.debug("Closing {}",endPoint);
            endPoint.close();
        }
    }
View Full Code Here

        flusher.enqueue(frame,callback, batchMode);
    }

    private int read(ByteBuffer buffer)
    {
        EndPoint endPoint = getEndPoint();
        try
        {
            while (true) // TODO: should this honor the LogicalConnection.suspend() ?
            {
                int filled = endPoint.fill(buffer);
                if (filled == 0)
                {
                    return 0;
                }
                else if (filled < 0)
View Full Code Here

  
    @Override
    public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        HttpConnection connection = HttpConnection.getCurrentConnection();
        final EndPoint endp = connection==null?null:connection.getEndPoint();
       
        final long idle_timeout;
        if (endp==null)
            idle_timeout=-1;
        else
        {
            idle_timeout=endp.getIdleTimeout();
            endp.setIdleTimeout(_idleTimeoutMs);
        }
       
        try
        {
            super.handle(target,baseRequest,request,response);
        }
        finally
        {
            if (endp!=null)
            {
                if (_applyToAsync && request.isAsyncStarted())
                {
                    request.getAsyncContext().addListener(new AsyncListener()
                    {
                        @Override
                        public void onTimeout(AsyncEvent event) throws IOException
                        {                           
                        }
                       
                        @Override
                        public void onStartAsync(AsyncEvent event) throws IOException
                        {
                        }
                       
                        @Override
                        public void onError(AsyncEvent event) throws IOException
                        {
                            endp.setIdleTimeout(idle_timeout);
                        }
                       
                        @Override
                        public void onComplete(AsyncEvent event) throws IOException
                        {
                            endp.setIdleTimeout(idle_timeout);
                        }
                    });
                }
                else
                    endp.setIdleTimeout(idle_timeout);
            }
        }
    }
View Full Code Here

    {
        // Get the real remote IP (not the one set by the forwarded headers (which may be forged))
        HttpChannel<?> channel = baseRequest.getHttpChannel();
        if (channel!=null)
        {
            EndPoint endp=channel.getEndPoint();
            if (endp!=null)
            {
                InetSocketAddress address = endp.getRemoteAddress();
                if (address!=null && !isAddrUriAllowed(address.getHostString(),baseRequest.getPathInfo()))
                {
                    response.sendError(HttpStatus.FORBIDDEN_403);
                    baseRequest.setHandled(true);
                    return;
View Full Code Here

        SslConnection sslConnection = newSslConnection(connector, endPoint, engine);
        sslConnection.setRenegotiationAllowed(_sslContextFactory.isRenegotiationAllowed());
        configure(sslConnection, connector, endPoint);

        ConnectionFactory next = connector.getConnectionFactory(_nextProtocol);
        EndPoint decryptedEndPoint = sslConnection.getDecryptedEndPoint();
        Connection connection = next.newConnection(connector, decryptedEndPoint);
        decryptedEndPoint.setConnection(connection);

        return sslConnection;
    }
View Full Code Here

        context.put(SSL_ENGINE_CONTEXT_KEY, engine);

        SslConnection sslConnection = newSslConnection(byteBufferPool, executor, endPoint, engine);
        sslConnection.setRenegotiationAllowed(sslContextFactory.isRenegotiationAllowed());
        endPoint.setConnection(sslConnection);
        EndPoint appEndPoint = sslConnection.getDecryptedEndPoint();
        appEndPoint.setConnection(connectionFactory.newConnection(appEndPoint, context));

        return sslConnection;
    }
View Full Code Here

    }

    public void receive()
    {
        HttpConnectionOverHTTP connection = getHttpConnection();
        EndPoint endPoint = connection.getEndPoint();
        HttpClient client = getHttpDestination().getHttpClient();
        ByteBufferPool bufferPool = client.getByteBufferPool();
        ByteBuffer buffer = bufferPool.acquire(client.getResponseBufferSize(), true);
        try
        {
            while (true)
            {
                // Connection may be closed in a parser callback
                if (connection.isClosed())
                {
                    LOG.debug("{} closed", connection);
                    break;
                }
                else
                {
                    int read = endPoint.fill(buffer);
                    if (LOG.isDebugEnabled()) // Avoid boxing of variable 'read'
                        LOG.debug("Read {} bytes from {}", read, endPoint);
                    if (read > 0)
                    {
                        parse(buffer);
View Full Code Here

        {
            Request request = exchange.getRequest();
            normalizeRequest(request);

            // Save the old idle timeout to restore it
            EndPoint endPoint = getEndPoint();
            idleTimeout = endPoint.getIdleTimeout();
            endPoint.setIdleTimeout(request.getIdleTimeout());

            // One channel per connection, just delegate the send
            channel.associate(exchange);
            channel.send();
        }
View Full Code Here

                            toWrite[1] = chunk;
                            toRecycle[1] = chunk;
                        }
                        if (hasContent)
                            toWrite[toWrite.length - 1] = contentBuffer;
                        EndPoint endPoint = getHttpChannel().getHttpConnection().getEndPoint();
                        endPoint.write(new ByteBufferRecyclerCallback(callback, bufferPool, toRecycle), toWrite);
                        return;
                    }
                    default:
                    {
                        throw new IllegalStateException(result.toString());
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.io.EndPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.