Package org.apache.http.nio.reactor

Examples of org.apache.http.nio.reactor.IOSession


        return entry.getEffectiveRoute();
    }

    public SSLSession getSSLSession() {
        OperatedAsyncClientConnection conn = ensureConnection();
        IOSession iosession = conn.getIOSession();
        if (iosession instanceof SSLIOSession) {
            return ((SSLIOSession) iosession).getSSLSession();
        } else {
            return null;
        }
View Full Code Here


            throw new IllegalStateException("Connection already open");
        }

        HttpHost target = route.getTargetHost();
        HttpHost proxy = route.getProxyHost();
        IOSession iosession = entry.getConnection();

        if (proxy == null) {
            AsyncScheme scheme = this.manager.getSchemeRegistry().getScheme(target);
            LayeringStrategy layeringStrategy = scheme.getLayeringStrategy();
            if (layeringStrategy != null) {
                iosession = layeringStrategy.layer(iosession);
            }
        }

        OperatedAsyncClientConnection conn = new DefaultAsyncClientConnection(
                "http-outgoing-" + entry.getId(),
                iosession,
                createHttpResponseFactory(),
                createByteBufferAllocator(),
                params);
        iosession.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);

        if (proxy == null) {
            tracker.connectTarget(conn.getIOSession() instanceof SSLIOSession);
        } else {
            tracker.connectProxy(proxy, false);
View Full Code Here

        LayeringStrategy layeringStrategy = scheme.getLayeringStrategy();
        if (layeringStrategy == null) {
            throw new IllegalStateException(scheme.getName() +
                    " scheme does not provider support for protocol layering");
        }
        IOSession iosession = entry.getConnection();
        OperatedAsyncClientConnection conn = (OperatedAsyncClientConnection) iosession.getAttribute(
                ExecutionContext.HTTP_CONNECTION);
        conn.upgrade((SSLIOSession) layeringStrategy.layer(iosession));
        tracker.layerProtocol(layeringStrategy.isSecure());
    }
View Full Code Here

    public synchronized void abortConnection() {
        if (this.poolEntry == null) {
            return;
        }
        this.reusable = false;
        IOSession iosession = this.poolEntry.getConnection();
        OperatedAsyncClientConnection conn = (OperatedAsyncClientConnection) iosession.getAttribute(
                ExecutionContext.HTTP_CONNECTION);
        try {
            conn.shutdown();
        } catch (IOException ignore) {
        }
View Full Code Here

        }
        return expired;
    }

    public OperatedAsyncClientConnection getOperatedClientConnection() {
        IOSession session = getConnection();
        return (OperatedAsyncClientConnection) session.getAttribute(
                ExecutionContext.HTTP_CONNECTION);
    }
View Full Code Here

        }
    }

    @Override
    public boolean isClosed() {
        IOSession session = getConnection();
        return session.isClosed();
    }
View Full Code Here

    protected final void onContentReceived(
            final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
        Asserts.notNull(this.bbuf, "Byte buffer");

        //FIXME: IOControl needs to expose event mask in order to avoid this extreme ugliness
        final IOSession iosession;
        if (ioctrl instanceof ManagedNHttpClientConnection) {
            final ManagedNHttpClientConnection conn = (ManagedNHttpClientConnection) ioctrl;
            iosession = conn != null ? conn.getIOSession() : null;
        } else {
            iosession = null;
        }
        while (!this.isDone()) {
            final int bytesRead = decoder.read(this.bbuf);
            if (bytesRead <= 0) {
                break;
            }
            this.bbuf.flip();
            onByteReceived(this.bbuf, ioctrl);
            this.bbuf.clear();
            if (decoder.isCompleted()) {
                break;
            } else {
                if (iosession != null && (iosession.isClosed()
                        || (iosession.getEventMask() & SelectionKey.OP_READ) == 0)) {
                    break;
                }
            }
        }
    }
View Full Code Here

    protected final void onContentReceived(
            final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
        Asserts.notNull(this.bbuf, "Byte buffer");

        //FIXME: IOControl needs to expose event mask in order to avoid this extreme ugliness
        final IOSession iosession;
        if (ioctrl instanceof ManagedNHttpClientConnection) {
            final ManagedNHttpClientConnection conn = (ManagedNHttpClientConnection) ioctrl;
            iosession = conn != null ? conn.getIOSession() : null;
        } else {
            iosession = null;
        }
        while (!this.isDone()) {
            final int bytesRead = decoder.read(this.bbuf);
            if (bytesRead <= 0) {
                break;
            }
            this.bbuf.flip();
            final boolean completed = decoder.isCompleted();
            CoderResult result = this.chardecoder.decode(this.bbuf, this.cbuf, completed);
            handleDecodingResult(result, ioctrl);
            this.bbuf.compact();
            if (completed) {
                result = this.chardecoder.flush(this.cbuf);
                handleDecodingResult(result, ioctrl);
                break;
            } else {
                if (iosession != null && (iosession.isClosed() ||
                        (iosession.getEventMask() & SelectionKey.OP_READ) == 0)) {
                    break;
                }
            }
        }
    }
View Full Code Here

     * This method dispatches the event notification to the
     * {@link IOEventDispatch#inputReady(IOSession)} method.
     */
    @Override
    protected void readable(final SelectionKey key) {
        IOSession session = getSession(key);
        try {
            this.eventDispatch.inputReady(session);
            if (session.hasBufferedInput()) {
                this.bufferingSessions.add(session);
            }
        } catch (CancelledKeyException ex) {
            queueClosedSession(session);
            key.attach(null);
View Full Code Here

     * This method dispatches the event notification to the
     * {@link IOEventDispatch#outputReady(IOSession)} method.
     */
    @Override
    protected void writable(final SelectionKey key) {
        IOSession session = getSession(key);
        try {
            this.eventDispatch.outputReady(session);
        } catch (CancelledKeyException ex) {
            queueClosedSession(session);
            key.attach(null);
View Full Code Here

TOP

Related Classes of org.apache.http.nio.reactor.IOSession

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.