extraData = null; if(!doHttp2PriRead(connection, buffer, serverConnection, extraData)) { request.getReadSetter().set(new ChannelListener<StreamSourceChannel>() { @Override
@Override protected void exchangeComplete(HttpServerExchange exchange) { if(fixedLengthStreamSinkConduit != null) { fixedLengthStreamSinkConduit.clearExchange(); } if (pipelineBuffer == null) { readListener.exchangeComplete(exchange); } else { pipelineBuffer.exchangeComplete(exchange); } }
@Override public void run() { handleEvent(connection.getChannel().getSourceChannel()); }
private boolean handleHttp2PriorKnowledge(PooledByteBuffer pooled, HttpServerExchange httpServerExchange) throws IOException { if(httpServerExchange.getRequestMethod().equals(PRI) && connection.getUndertowOptions().get(UndertowOptions.ENABLE_HTTP2, false)) { handleHttp2PriorKnowledge(connection.getChannel(), connection, pooled); return false; } else { sendBadRequestAndClose(connection.getChannel(), new IOException()); return true; } }
handleFailedRead(channel, res); return; } else { if (read > maxRequestSize) { UndertowLogger.REQUEST_LOGGER.requestHeaderWasTooLarge(connection.getPeerAddress(), maxRequestSize); sendBadRequestAndClose(connection.getChannel(), null); return; free = handleHttp2PriorKnowledge(pooled, httpServerExchange); return; if(protocol != Protocols.HTTP_1_1 && protocol != Protocols.HTTP_1_0 && protocol != Protocols.HTTP_0_9) { UndertowLogger.REQUEST_IO_LOGGER.debugf("Closing connection from %s due to unknown protocol %s", connection.getChannel().getPeerAddress(), protocol); sendBadRequestAndClose(connection.getChannel(), new IOException()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.moreThanOneHostHeader()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.noHostInHttp11Request()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.invalidHeaders()); return; sendBadRequestAndClose(connection.getChannel(), t); return; } finally {
HttpReadListener readListener = new HttpReadListener(connection, parser, statisticsEnabled ? connectorStatistics : null); readListener.newRequest(); channel.getSourceChannel().setReadListener(readListener); readListener.handleEvent(channel.getSourceChannel());
connection.setCurrentExchange(null); final HttpServerConnection connection = this.connection; if (exchange.isPersistent() && !isUpgradeOrConnect(exchange)) { final StreamConnection channel = connection.getChannel(); if (connection.getExtraBytes() == null) { newRequest(); channel.getSourceChannel().setReadListener(HttpReadListener.this); channel.getSourceChannel().resumeReads(); if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { newRequest(); channel.getSourceChannel().setReadListener(HttpReadListener.this); channel.getSourceChannel().resumeReads(); if (exchange.isInIoThread()) { requestStateUpdater.set(this, 0); //no need to CAS, as we don't actually resume newRequest(); } else if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { newRequest(); channel.getSourceChannel().suspendReads(); } finally {
public void handleEvent(final ConduitStreamSourceChannel channel) { while (requestStateUpdater.get(this) != 0) { //if the CAS fails it is because another thread is in the process of changing state //we just immediately retry if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { channel.suspendReads(); } finally { requestStateUpdater.set(this, 1); } return; } } handleEventWithNoRunningRequest(channel); }
HttpReadListener readListener = new HttpReadListener(connection, parser, statisticsEnabled ? connectorStatistics : null); readListener.newRequest(); channel.getSourceChannel().setReadListener(readListener); readListener.handleEvent(channel.getSourceChannel());
handleFailedRead(channel, res); return; } else { if (read > maxRequestSize) { UndertowLogger.REQUEST_LOGGER.requestHeaderWasTooLarge(connection.getPeerAddress(), maxRequestSize); sendBadRequestAndClose(connection.getChannel(), null); return; free = handleHttp2PriorKnowledge(pooled, httpServerExchange); return; if(protocol != Protocols.HTTP_1_1 && protocol != Protocols.HTTP_1_0 && protocol != Protocols.HTTP_0_9) { UndertowLogger.REQUEST_IO_LOGGER.debugf("Closing connection from %s due to unknown protocol %s", connection.getChannel().getPeerAddress(), protocol); sendBadRequestAndClose(connection.getChannel(), new IOException()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.moreThanOneHostHeader()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.noHostInHttp11Request()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.invalidHeaders()); return; sendBadRequestAndClose(connection.getChannel(), t); return; } finally {
private boolean handleHttp2PriorKnowledge(PooledByteBuffer pooled, HttpServerExchange httpServerExchange) throws IOException { if(httpServerExchange.getRequestMethod().equals(PRI) && connection.getUndertowOptions().get(UndertowOptions.ENABLE_HTTP2, false)) { handleHttp2PriorKnowledge(connection.getChannel(), connection, pooled); return false; } else { sendBadRequestAndClose(connection.getChannel(), new IOException()); return true; } }
connection.setCurrentExchange(null); final HttpServerConnection connection = this.connection; if (exchange.isPersistent() && !isUpgradeOrConnect(exchange)) { final StreamConnection channel = connection.getChannel(); if (connection.getExtraBytes() == null) { newRequest(); channel.getSourceChannel().setReadListener(HttpReadListener.this); channel.getSourceChannel().resumeReads(); if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { newRequest(); channel.getSourceChannel().setReadListener(HttpReadListener.this); channel.getSourceChannel().resumeReads(); if (exchange.isInIoThread()) { requestStateUpdater.set(this, 0); //no need to CAS, as we don't actually resume newRequest(); } else if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { newRequest(); channel.getSourceChannel().suspendReads(); } finally {
public void handleEvent(final ConduitStreamSourceChannel channel) { while (requestStateUpdater.get(this) != 0) { //if the CAS fails it is because another thread is in the process of changing state //we just immediately retry if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { channel.suspendReads(); } finally { requestStateUpdater.set(this, 1); } return; } } handleEventWithNoRunningRequest(channel); }
HttpReadListener readListener = new HttpReadListener(connection, parser, statisticsEnabled ? connectorStatistics : null); readListener.newRequest(); channel.getSourceChannel().setReadListener(readListener); readListener.handleEvent(channel.getSourceChannel());
handleFailedRead(channel, res); return; } else { if (read > maxRequestSize) { UndertowLogger.REQUEST_LOGGER.requestHeaderWasTooLarge(connection.getPeerAddress(), maxRequestSize); sendBadRequestAndClose(connection.getChannel(), null); return; free = handleHttp2PriorKnowledge(pooled, httpServerExchange); return; if(protocol != Protocols.HTTP_1_1 && protocol != Protocols.HTTP_1_0 && protocol != Protocols.HTTP_0_9) { UndertowLogger.REQUEST_IO_LOGGER.debugf("Closing connection from %s due to unknown protocol %s", connection.getChannel().getPeerAddress(), protocol); sendBadRequestAndClose(connection.getChannel(), new IOException()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.moreThanOneHostHeader()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.noHostInHttp11Request()); return; sendBadRequestAndClose(connection.getChannel(), UndertowMessages.MESSAGES.invalidHeaders()); return; sendBadRequestAndClose(connection.getChannel(), t); return; } finally {
public void exchangeComplete(final HttpServerExchange exchange) { //if we ever fail to read then we flush the pipeline buffer //this relies on us always doing an eager read when starting a request, //rather than waiting to be notified of data being available final HttpServerConnection connection = (HttpServerConnection) exchange.getConnection(); if (connection.getExtraBytes() == null || exchange.isUpgrade()) { performFlush(exchange, connection); } else { connection.getReadListener().exchangeComplete(exchange); } }
private boolean handleHttp2PriorKnowledge(PooledByteBuffer pooled, HttpServerExchange httpServerExchange) throws IOException { if(httpServerExchange.getRequestMethod().equals(PRI) && connection.getUndertowOptions().get(UndertowOptions.ENABLE_HTTP2, false)) { handleHttp2PriorKnowledge(connection.getChannel(), connection, pooled); return false; } else { sendBadRequestAndClose(connection.getChannel(), new IOException()); return true; } }
public void exchangeComplete(final HttpServerExchange exchange) { connection.clearChannel(); final HttpServerConnection connection = this.connection; if (exchange.isPersistent() && !isUpgradeOrConnect(exchange)) { final StreamConnection channel = connection.getChannel(); if (connection.getExtraBytes() == null) { newRequest(); channel.getSourceChannel().setReadListener(HttpReadListener.this); channel.getSourceChannel().resumeReads(); if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { newRequest(); channel.getSourceChannel().setReadListener(HttpReadListener.this); channel.getSourceChannel().resumeReads(); if (exchange.isInIoThread()) { requestStateUpdater.set(this, 0); //no need to CAS, as we don't actually resume newRequest(); } else if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { newRequest(); channel.getSourceChannel().suspendReads(); } finally {
@Override public void run() { handleEvent(connection.getChannel().getSourceChannel()); }
public void handleEvent(final ConduitStreamSourceChannel channel) { while (requestStateUpdater.get(this) != 0) { //if the CAS fails it is because another thread is in the process of changing state //we just immediately retry if (requestStateUpdater.compareAndSet(this, 1, 2)) { try { channel.suspendReads(); } finally { requestStateUpdater.set(this, 1); } return; } } handleEventWithNoRunningRequest(channel); }