You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/09/07 01:07:00 UTC
svn commit: r1165921 - in /tomcat/trunk/java/org/apache/coyote/http11:
AbstractHttp11Processor.java Http11AprProcessor.java
Http11NioProcessor.java Http11Processor.java
Author: markt
Date: Tue Sep 6 23:07:00 2011
New Revision: 1165921
URL: http://svn.apache.org/viewvc?rev=1165921&view=rev
Log:
Pull up the process() method
Modified:
tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1165921&r1=1165920&r2=1165921&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Sep 6 23:07:00 2011
@@ -638,6 +638,12 @@ public abstract class AbstractHttp11Proc
status == 501 /* SC_NOT_IMPLEMENTED */;
}
+
+ /**
+ * Allows the super class to set the socket wrapper being used.
+ */
+ protected abstract void setSocketWrapper(SocketWrapper<S> socketWrapper);
+
/**
* Exposes input buffer to super class to allow better code re-use.
@@ -838,6 +844,211 @@ public abstract class AbstractHttp11Proc
/**
+ * Process pipelined HTTP requests using the specified input and output
+ * streams.
+ *
+ * @param socketWrapper Socket from which the HTTP requests will be read
+ * and the HTTP responses will be written.
+ *
+ * @throws IOException error during an I/O operation
+ */
+ @Override
+ public SocketState process(SocketWrapper<S> socketWrapper)
+ throws IOException {
+ RequestInfo rp = request.getRequestProcessor();
+ rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
+
+ // Setting up the I/O
+ setSocketWrapper(socketWrapper);
+ getInputBuffer().init(socketWrapper, endpoint);
+ getOutputBuffer().init(socketWrapper, endpoint);
+
+ // Flags
+ error = false;
+ keepAlive = true;
+ comet = false;
+ openSocket = false;
+ sendfileInProgress = false;
+ readComplete = true;
+ if (endpoint.getUsePolling()) {
+ keptAlive = false;
+ } else {
+ keptAlive = socketWrapper.isKeptAlive();
+ }
+
+ if (disableKeepAlive()) {
+ socketWrapper.setKeepAliveLeft(0);
+ }
+
+ while (!error && keepAlive && !comet && !isAsync() &&
+ !endpoint.isPaused()) {
+
+ // Parsing the request header
+ try {
+ setRequestLineReadTimeout();
+
+ if (!getInputBuffer().parseRequestLine(keptAlive)) {
+ if (handleIncompleteRequestLineRead()) {
+ break;
+ }
+ }
+
+ if (endpoint.isPaused()) {
+ // 503 - Service unavailable
+ response.setStatus(503);
+ adapter.log(request, response, 0);
+ error = true;
+ } else {
+ request.setStartTime(System.currentTimeMillis());
+ keptAlive = true;
+ // Currently only NIO will ever return false here
+ if (!getInputBuffer().parseHeaders()) {
+ // We've read part of the request, don't recycle it
+ // instead associate it with the socket
+ openSocket = true;
+ readComplete = false;
+ break;
+ }
+ if (!disableUploadTimeout) {
+ setSocketTimeout(connectionUploadTimeout);
+ }
+ }
+ } catch (IOException e) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(
+ sm.getString("http11processor.header.parse"), e);
+ }
+ error = true;
+ break;
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(
+ sm.getString("http11processor.header.parse"), t);
+ }
+ // 400 - Bad Request
+ response.setStatus(400);
+ adapter.log(request, response, 0);
+ error = true;
+ }
+
+ if (!error) {
+ // Setting up filters, and parse some request headers
+ rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
+ try {
+ prepareRequest();
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(sm.getString(
+ "http11processor.request.prepare"), t);
+ }
+ // 400 - Internal Server Error
+ response.setStatus(400);
+ adapter.log(request, response, 0);
+ error = true;
+ }
+ }
+
+ if (maxKeepAliveRequests == 1) {
+ keepAlive = false;
+ } else if (maxKeepAliveRequests > 0 &&
+ socketWrapper.decrementKeepAlive() <= 0) {
+ keepAlive = false;
+ }
+
+ // Process the request in the adapter
+ if (!error) {
+ try {
+ rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
+ adapter.service(request, response);
+ // Handle when the response was committed before a serious
+ // error occurred. Throwing a ServletException should both
+ // set the status to 500 and set the errorException.
+ // If we fail here, then the response is likely already
+ // committed, so we can't try and set headers.
+ if(keepAlive && !error) { // Avoid checking twice.
+ error = response.getErrorException() != null ||
+ (!isAsync() &&
+ statusDropsConnection(response.getStatus()));
+ }
+ setCometTimeouts(socketWrapper);
+ } catch (InterruptedIOException e) {
+ error = true;
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ getLog().error(sm.getString(
+ "http11processor.request.process"), t);
+ // 500 - Internal Server Error
+ response.setStatus(500);
+ adapter.log(request, response, 0);
+ error = true;
+ }
+ }
+
+ // Finish the handling of the request
+ rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);
+
+ if (!isAsync() && !comet) {
+ if (error) {
+ // If we know we are closing the connection, don't drain
+ // input. This way uploading a 100GB file doesn't tie up the
+ // thread if the servlet has rejected it.
+ getInputBuffer().setSwallowInput(false);
+ }
+ endRequest();
+ }
+
+ rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);
+
+ // If there was an error, make sure the request is counted as
+ // and error, and update the statistics counter
+ if (error) {
+ response.setStatus(500);
+ }
+ request.updateCounters();
+
+ if (!isAsync() && !comet || error) {
+ getInputBuffer().nextRequest();
+ getOutputBuffer().nextRequest();
+ }
+
+ if (!disableUploadTimeout) {
+ setSocketTimeout(endpoint.getSoTimeout());
+ }
+
+ rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
+
+ if (breakKeepAliveLoop(socketWrapper)) {
+ break;
+ }
+ }
+
+ rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
+
+ if (error || endpoint.isPaused()) {
+ return SocketState.CLOSED;
+ } else if (comet || isAsync()) {
+ return SocketState.LONG;
+ } else {
+ if (sendfileInProgress) {
+ return SocketState.SENDFILE;
+ } else {
+ if (openSocket) {
+ if (readComplete) {
+ return SocketState.OPEN;
+ } else {
+ return SocketState.LONG;
+ }
+ } else {
+ return SocketState.CLOSED;
+ }
+ }
+ }
+ }
+
+
+ /**
* After reading the request headers, we have to setup the request filters.
*/
protected void prepareRequest() {
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1165921&r1=1165920&r2=1165921&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Tue Sep 6 23:07:00 2011
@@ -157,207 +157,6 @@ public class Http11AprProcessor extends
}
}
- /**
- * Process pipelined HTTP requests using the specified input and output
- * streams.
- *
- * @param socketWrapper Socket from which the HTTP requests will be read
- * and the HTTP responses will be written.
- *
- * @throws IOException error during an I/O operation
- */
- @Override
- public SocketState process(SocketWrapper<Long> socketWrapper)
- throws IOException {
- RequestInfo rp = request.getRequestProcessor();
- rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
-
- // Setting up the I/O
- this.socket = socketWrapper;
- inputBuffer.init(socketWrapper, endpoint);
- outputBuffer.init(socketWrapper, endpoint);
-
- // Flags
- error = false;
- keepAlive = true;
- comet = false;
- openSocket = false;
- sendfileInProgress = false;
- readComplete = true;
- if (endpoint.getUsePolling()) {
- keptAlive = false;
- } else {
- keptAlive = socketWrapper.isKeptAlive();
- }
-
- if (disableKeepAlive()) {
- socketWrapper.setKeepAliveLeft(0);
- }
-
- while (!error && keepAlive && !comet && !isAsync() &&
- !endpoint.isPaused()) {
-
- // Parsing the request header
- try {
- setRequestLineReadTimeout();
-
- if (!inputBuffer.parseRequestLine(keptAlive)) {
- if (handleIncompleteRequestLineRead()) {
- break;
- }
- }
-
- if (endpoint.isPaused()) {
- // 503 - Service unavailable
- response.setStatus(503);
- adapter.log(request, response, 0);
- error = true;
- } else {
- request.setStartTime(System.currentTimeMillis());
- keptAlive = true;
- // Currently only NIO will ever return false here
- if (!inputBuffer.parseHeaders()) {
- // We've read part of the request, don't recycle it
- // instead associate it with the socket
- openSocket = true;
- readComplete = false;
- break;
- }
- if (!disableUploadTimeout) {
- setSocketTimeout(connectionUploadTimeout);
- }
- }
- } catch (IOException e) {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.header.parse"), e);
- }
- error = true;
- break;
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.header.parse"), t);
- }
- // 400 - Bad Request
- response.setStatus(400);
- adapter.log(request, response, 0);
- error = true;
- }
-
- if (!error) {
- // Setting up filters, and parse some request headers
- rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
- try {
- prepareRequest();
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.request.prepare"), t);
- }
- // 400 - Internal Server Error
- response.setStatus(400);
- adapter.log(request, response, 0);
- error = true;
- }
- }
-
- if (maxKeepAliveRequests == 1) {
- keepAlive = false;
- } else if (maxKeepAliveRequests > 0 &&
- socketWrapper.decrementKeepAlive() <= 0) {
- keepAlive = false;
- }
-
- // Process the request in the adapter
- if (!error) {
- try {
- rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
- adapter.service(request, response);
- // Handle when the response was committed before a serious
- // error occurred. Throwing a ServletException should both
- // set the status to 500 and set the errorException.
- // If we fail here, then the response is likely already
- // committed, so we can't try and set headers.
- if(keepAlive && !error) { // Avoid checking twice.
- error = response.getErrorException() != null ||
- (!isAsync() &&
- statusDropsConnection(response.getStatus()));
- }
- setCometTimeouts(socketWrapper);
- } catch (InterruptedIOException e) {
- error = true;
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- log.error(sm.getString("http11processor.request.process"), t);
- // 500 - Internal Server Error
- response.setStatus(500);
- adapter.log(request, response, 0);
- error = true;
- }
- }
-
- // Finish the handling of the request
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);
-
- if (!isAsync() && !comet) {
- if (error) {
- // If we know we are closing the connection, don't drain
- // input. This way uploading a 100GB file doesn't tie up the
- // thread if the servlet has rejected it.
- inputBuffer.setSwallowInput(false);
- }
- endRequest();
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);
-
- // If there was an error, make sure the request is counted as
- // and error, and update the statistics counter
- if (error) {
- response.setStatus(500);
- }
- request.updateCounters();
-
- if (!isAsync() && !comet || error) {
- inputBuffer.nextRequest();
- outputBuffer.nextRequest();
- }
-
- if (!disableUploadTimeout) {
- setSocketTimeout(endpoint.getSoTimeout());
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-
- if (breakKeepAliveLoop(socketWrapper)) {
- break;
- }
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
-
- if (error || endpoint.isPaused()) {
- return SocketState.CLOSED;
- } else if (comet || isAsync()) {
- return SocketState.LONG;
- } else {
- if (sendfileInProgress) {
- return SocketState.SENDFILE;
- } else {
- if (openSocket) {
- if (readComplete) {
- return SocketState.OPEN;
- } else {
- return SocketState.LONG;
- }
- } else {
- return SocketState.CLOSED;
- }
- }
- }
- }
-
-
@Override
protected boolean disableKeepAlive() {
return false;
@@ -718,6 +517,11 @@ public class Http11AprProcessor extends
}
@Override
+ protected void setSocketWrapper(SocketWrapper<Long> socketWrapper) {
+ this.socket = socketWrapper;
+ }
+
+ @Override
protected AbstractInputBuffer<Long> getInputBuffer() {
return inputBuffer;
}
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1165921&r1=1165920&r2=1165921&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Tue Sep 6 23:07:00 2011
@@ -186,207 +186,6 @@ public class Http11NioProcessor extends
}
- /**
- * Process pipelined HTTP requests using the specified input and output
- * streams.
- *
- * @param socketWrapper Socket from which the HTTP requests will be read
- * and the HTTP responses will be written.
- *
- * @throws IOException error during an I/O operation
- */
- @Override
- public SocketState process(SocketWrapper<NioChannel> socketWrapper)
- throws IOException {
- RequestInfo rp = request.getRequestProcessor();
- rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
-
- // Setting up the I/O
- this.socket = socketWrapper;
- inputBuffer.init(socketWrapper, endpoint);
- outputBuffer.init(socketWrapper, endpoint);
-
- // Flags
- error = false;
- keepAlive = true;
- comet = false;
- openSocket = false;
- sendfileInProgress = false;
- readComplete = true;
- if (endpoint.getUsePolling()) {
- keptAlive = false;
- } else {
- keptAlive = socketWrapper.isKeptAlive();
- }
-
- if (disableKeepAlive()) {
- socketWrapper.setKeepAliveLeft(0);
- }
-
- while (!error && keepAlive && !comet && !isAsync() &&
- !endpoint.isPaused()) {
-
- // Parsing the request header
- try {
- setRequestLineReadTimeout();
-
- if (!inputBuffer.parseRequestLine(keptAlive)) {
- if (handleIncompleteRequestLineRead()) {
- break;
- }
- }
-
- if (endpoint.isPaused()) {
- // 503 - Service unavailable
- response.setStatus(503);
- adapter.log(request, response, 0);
- error = true;
- } else {
- request.setStartTime(System.currentTimeMillis());
- keptAlive = true;
- // Currently only NIO will ever return false here
- if (!inputBuffer.parseHeaders()) {
- // We've read part of the request, don't recycle it
- // instead associate it with the socket
- openSocket = true;
- readComplete = false;
- break;
- }
- if (!disableUploadTimeout) {
- setSocketTimeout(connectionUploadTimeout);
- }
- }
- } catch (IOException e) {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.header.parse"), e);
- }
- error = true;
- break;
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.header.parse"), t);
- }
- // 400 - Bad Request
- response.setStatus(400);
- adapter.log(request, response, 0);
- error = true;
- }
-
- if (!error) {
- // Setting up filters, and parse some request headers
- rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
- try {
- prepareRequest();
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.request.prepare"), t);
- }
- // 400 - Internal Server Error
- response.setStatus(400);
- adapter.log(request, response, 0);
- error = true;
- }
- }
-
- if (maxKeepAliveRequests == 1) {
- keepAlive = false;
- } else if (maxKeepAliveRequests > 0 &&
- socketWrapper.decrementKeepAlive() <= 0) {
- keepAlive = false;
- }
-
- // Process the request in the adapter
- if (!error) {
- try {
- rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
- adapter.service(request, response);
- // Handle when the response was committed before a serious
- // error occurred. Throwing a ServletException should both
- // set the status to 500 and set the errorException.
- // If we fail here, then the response is likely already
- // committed, so we can't try and set headers.
- if(keepAlive && !error) { // Avoid checking twice.
- error = response.getErrorException() != null ||
- (!isAsync() &&
- statusDropsConnection(response.getStatus()));
- }
- setCometTimeouts(socketWrapper);
- } catch (InterruptedIOException e) {
- error = true;
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- log.error(sm.getString("http11processor.request.process"), t);
- // 500 - Internal Server Error
- response.setStatus(500);
- adapter.log(request, response, 0);
- error = true;
- }
- }
-
- // Finish the handling of the request
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);
-
- if (!isAsync() && !comet) {
- if (error) {
- // If we know we are closing the connection, don't drain
- // input. This way uploading a 100GB file doesn't tie up the
- // thread if the servlet has rejected it.
- inputBuffer.setSwallowInput(false);
- }
- endRequest();
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);
-
- // If there was an error, make sure the request is counted as
- // and error, and update the statistics counter
- if (error) {
- response.setStatus(500);
- }
- request.updateCounters();
-
- if (!isAsync() && !comet || error) {
- inputBuffer.nextRequest();
- outputBuffer.nextRequest();
- }
-
- if (!disableUploadTimeout) {
- setSocketTimeout(endpoint.getSoTimeout());
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-
- if (breakKeepAliveLoop(socketWrapper)) {
- break;
- }
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
-
- if (error || endpoint.isPaused()) {
- return SocketState.CLOSED;
- } else if (comet || isAsync()) {
- return SocketState.LONG;
- } else {
- if (sendfileInProgress) {
- return SocketState.SENDFILE;
- } else {
- if (openSocket) {
- if (readComplete) {
- return SocketState.OPEN;
- } else {
- return SocketState.LONG;
- }
- } else {
- return SocketState.CLOSED;
- }
- }
- }
- }
-
-
@Override
protected boolean disableKeepAlive() {
return false;
@@ -733,6 +532,11 @@ public class Http11NioProcessor extends
}
@Override
+ protected void setSocketWrapper(SocketWrapper<NioChannel> socketWrapper) {
+ this.socket = socketWrapper;
+ }
+
+ @Override
protected AbstractInputBuffer<NioChannel> getInputBuffer() {
return inputBuffer;
}
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1165921&r1=1165920&r2=1165921&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Tue Sep 6 23:07:00 2011
@@ -18,16 +18,13 @@ package org.apache.coyote.http11;
import java.io.EOFException;
import java.io.IOException;
-import java.io.InterruptedIOException;
import java.net.InetAddress;
import java.net.Socket;
import org.apache.coyote.ActionCode;
-import org.apache.coyote.RequestInfo;
import org.apache.coyote.http11.filters.BufferedInputFilter;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
import org.apache.tomcat.util.net.JIoEndpoint;
import org.apache.tomcat.util.net.SSLSupport;
@@ -121,207 +118,6 @@ public class Http11Processor extends Abs
}
- /**
- * Process pipelined HTTP requests using the specified input and output
- * streams.
- *
- * @param socketWrapper Socket from which the HTTP requests will be read
- * and the HTTP responses will be written.
- *
- * @throws IOException error during an I/O operation
- */
- @Override
- public SocketState process(SocketWrapper<Socket> socketWrapper)
- throws IOException {
- RequestInfo rp = request.getRequestProcessor();
- rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
-
- // Setting up the I/O
- this.socket = socketWrapper;
- inputBuffer.init(socketWrapper, endpoint);
- outputBuffer.init(socketWrapper, endpoint);
-
- // Flags
- error = false;
- keepAlive = true;
- comet = false;
- openSocket = false;
- sendfileInProgress = false;
- readComplete = true;
- if (endpoint.getUsePolling()) {
- keptAlive = false;
- } else {
- keptAlive = socketWrapper.isKeptAlive();
- }
-
- if (disableKeepAlive()) {
- socketWrapper.setKeepAliveLeft(0);
- }
-
- while (!error && keepAlive && !comet && !isAsync() &&
- !endpoint.isPaused()) {
-
- // Parsing the request header
- try {
- setRequestLineReadTimeout();
-
- if (!inputBuffer.parseRequestLine(keptAlive)) {
- if (handleIncompleteRequestLineRead()) {
- break;
- }
- }
-
- if (endpoint.isPaused()) {
- // 503 - Service unavailable
- response.setStatus(503);
- adapter.log(request, response, 0);
- error = true;
- } else {
- request.setStartTime(System.currentTimeMillis());
- keptAlive = true;
- // Currently only NIO will ever return false here
- if (!inputBuffer.parseHeaders()) {
- // We've read part of the request, don't recycle it
- // instead associate it with the socket
- openSocket = true;
- readComplete = false;
- break;
- }
- if (!disableUploadTimeout) {
- setSocketTimeout(connectionUploadTimeout);
- }
- }
- } catch (IOException e) {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.header.parse"), e);
- }
- error = true;
- break;
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.header.parse"), t);
- }
- // 400 - Bad Request
- response.setStatus(400);
- adapter.log(request, response, 0);
- error = true;
- }
-
- if (!error) {
- // Setting up filters, and parse some request headers
- rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
- try {
- prepareRequest();
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.request.prepare"), t);
- }
- // 400 - Internal Server Error
- response.setStatus(400);
- adapter.log(request, response, 0);
- error = true;
- }
- }
-
- if (maxKeepAliveRequests == 1) {
- keepAlive = false;
- } else if (maxKeepAliveRequests > 0 &&
- socketWrapper.decrementKeepAlive() <= 0) {
- keepAlive = false;
- }
-
- // Process the request in the adapter
- if (!error) {
- try {
- rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
- adapter.service(request, response);
- // Handle when the response was committed before a serious
- // error occurred. Throwing a ServletException should both
- // set the status to 500 and set the errorException.
- // If we fail here, then the response is likely already
- // committed, so we can't try and set headers.
- if(keepAlive && !error) { // Avoid checking twice.
- error = response.getErrorException() != null ||
- (!isAsync() &&
- statusDropsConnection(response.getStatus()));
- }
- setCometTimeouts(socketWrapper);
- } catch (InterruptedIOException e) {
- error = true;
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- log.error(sm.getString("http11processor.request.process"), t);
- // 500 - Internal Server Error
- response.setStatus(500);
- adapter.log(request, response, 0);
- error = true;
- }
- }
-
- // Finish the handling of the request
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);
-
- if (!isAsync() && !comet) {
- if (error) {
- // If we know we are closing the connection, don't drain
- // input. This way uploading a 100GB file doesn't tie up the
- // thread if the servlet has rejected it.
- inputBuffer.setSwallowInput(false);
- }
- endRequest();
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);
-
- // If there was an error, make sure the request is counted as
- // and error, and update the statistics counter
- if (error) {
- response.setStatus(500);
- }
- request.updateCounters();
-
- if (!isAsync() && !comet || error) {
- inputBuffer.nextRequest();
- outputBuffer.nextRequest();
- }
-
- if (!disableUploadTimeout) {
- setSocketTimeout(endpoint.getSoTimeout());
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-
- if (breakKeepAliveLoop(socketWrapper)) {
- break;
- }
- }
-
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
-
- if (error || endpoint.isPaused()) {
- return SocketState.CLOSED;
- } else if (comet || isAsync()) {
- return SocketState.LONG;
- } else {
- if (sendfileInProgress) {
- return SocketState.SENDFILE;
- } else {
- if (openSocket) {
- if (readComplete) {
- return SocketState.OPEN;
- } else {
- return SocketState.LONG;
- }
- } else {
- return SocketState.CLOSED;
- }
- }
- }
- }
-
-
@Override
protected boolean disableKeepAlive() {
int threadRatio = -1;
@@ -601,6 +397,11 @@ public class Http11Processor extends Abs
}
@Override
+ protected void setSocketWrapper(SocketWrapper<Socket> socketWrapper) {
+ this.socket = socketWrapper;
+ }
+
+ @Override
protected AbstractInputBuffer<Socket> getInputBuffer() {
return inputBuffer;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org