You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@locus.apache.org on 2000/06/01 07:37:32 UTC
cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http HttpProcessor.java LocalStrings.properties
remm 00/05/31 22:37:32
Modified: proposals/catalina/src/share/org/apache/tomcat/connector/http
HttpProcessor.java LocalStrings.properties
Log:
- 100 Continue is no longer sent back unless the client requests it
Revision Changes Path
1.13 +47 -19 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/HttpProcessor.java
Index: HttpProcessor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/HttpProcessor.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- HttpProcessor.java 2000/05/31 21:14:23 1.12
+++ HttpProcessor.java 2000/06/01 05:37:31 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/HttpProcessor.java,v 1.12 2000/05/31 21:14:23 remm Exp $
- * $Revision: 1.12 $
- * $Date: 2000/05/31 21:14:23 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/HttpProcessor.java,v 1.13 2000/06/01 05:37:31 remm Exp $
+ * $Revision: 1.13 $
+ * $Date: 2000/06/01 05:37:31 $
*
* ====================================================================
*
@@ -103,7 +103,8 @@
* the request. When the processor is completed, it will recycle itself.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.12 $ $Date: 2000/05/31 21:14:23 $
+ * @author Remy Maucherat
+ * @version $Revision: 1.13 $ $Date: 2000/06/01 05:37:31 $
*/
final class HttpProcessor
@@ -242,6 +243,15 @@
/**
+ * True if the client has asked to recieve a request acknoledgement. If so
+ * the server will send a preliminary 100 Continue response just after it
+ * has successfully parsed the request headers, and before starting
+ * reading the request entity body.
+ */
+ private boolean sendAck = false;
+
+
+ /**
* Ack string when pipelining HTTP requests.
*/
private static final byte[] ack =
@@ -416,7 +426,8 @@
int equalIndex = language.indexOf('=');
Double qValue = new Double(1);
- if (qValueIndex > -1 && qValueIndex < qIndex && qIndex < equalIndex) {
+ if (qValueIndex > -1 && qValueIndex < qIndex
+ && qIndex < equalIndex) {
String qValueStr = language.substring(qValueIndex + 1);
language = language.substring(0, qValueIndex);
qValueStr = qValueStr.trim().toLowerCase();
@@ -435,7 +446,8 @@
// may need to handle "*" at some point in time
if (! language.equals("*")) {
String key = qValue.toString();
- Vector v = (Vector)((languages.containsKey(key)) ? languages.get(key) : new Vector());
+ Vector v = (Vector)((languages.containsKey(key))
+ ? languages.get(key) : new Vector());
v.addElement(language);
languages.put(key, v);
}
@@ -468,7 +480,8 @@
request.setRequestedSessionURL(false);
if (debug >= 1)
log(" Requested cookie session id is " +
- ((HttpServletRequest) request.getRequest()).getRequestedSessionId());
+ ((HttpServletRequest) request.getRequest())
+ .getRequestedSessionId());
} else
request.addCookie(cookies[i]);
}
@@ -481,7 +494,8 @@
n = Integer.parseInt(value);
} catch (Exception e) {
throw new ServletException
- (sm.getString("httpProcessor.parseHeaders.contentLength"));
+ (sm.getString
+ ("httpProcessor.parseHeaders.contentLength"));
}
request.setContentLength(n);
} else if (match.equals("content-type")) {
@@ -497,7 +511,8 @@
port = Integer.parseInt(value.substring(n+1).trim());
} catch (Exception e) {
throw new ServletException
- (sm.getString("httpProcessor.parseHeaders.portNumber"));
+ (sm.getString
+ ("httpProcessor.parseHeaders.portNumber"));
}
request.setServerPort(port);
}
@@ -510,6 +525,13 @@
keepAlive = true;
}
*/
+ } else if (match.equals("expect")) {
+ if ("100-continue".equalsIgnoreCase(value))
+ sendAck = true;
+ else
+ throw new ServletException
+ (sm.getString
+ ("httpProcessor.parseHeaders.unknownExpectation"));
} else {
request.addHeader(name, value);
}
@@ -562,19 +584,17 @@
// Now check if the connection should be kept alive after parsing the
// request.
- if ( protocol.equals("HTTP/1.1") )
+ if ( protocol.equals("HTTP/1.1") ) {
http11 = true;
- else {
+ sendAck = false;
+ } else {
http11 = false;
+ sendAck = false;
// For HTTP/1.0, connection are not persistent by default,
// unless specified with a Connection: Keep-Alive header.
keepAlive = false;
}
- if (http11) {
- ackRequest(output);
- }
-
// Validate the incoming request line
if (method == null) {
throw new ServletException
@@ -590,7 +610,8 @@
request.setQueryString(uri.substring(question + 1));
if (debug >= 1)
log(" Query string is " +
- ((HttpServletRequest) request.getRequest()).getQueryString());
+ ((HttpServletRequest) request.getRequest())
+ .getQueryString());
uri = uri.substring(0, question);
} else
request.setQueryString(null);
@@ -611,7 +632,8 @@
uri = uri.substring(0, semicolon) + rest;
if (debug >= 1)
log(" Requested URL session id is " +
- ((HttpServletRequest) request.getRequest()).getRequestedSessionId());
+ ((HttpServletRequest) request.getRequest())
+ .getRequestedSessionId());
} else {
request.setRequestedSessionId(null);
request.setRequestedSessionURL(false);
@@ -638,7 +660,8 @@
*/
private void ackRequest(OutputStream output)
throws IOException {
- output.write(ack);
+ if (sendAck)
+ output.write(ack);
}
@@ -691,8 +714,13 @@
if (!request.getRequest().getProtocol()
.startsWith("HTTP/0"))
parseHeaders(input);
- if (http11)
+ if (http11) {
+ // Sending a request acknowledge back to the client if
+ // requested.
+ ackRequest(output);
+ // If the protocol is HTTP/1.1, chunking is allowed.
((HttpResponseImpl) response).setAllowChunking(true);
+ }
}
} catch (Exception e) {
try {
1.5 +1 -0 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/LocalStrings.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LocalStrings.properties 2000/05/22 04:57:25 1.4
+++ LocalStrings.properties 2000/06/01 05:37:31 1.5
@@ -14,6 +14,7 @@
httpProcessor.parseRequest.method=Missing HTTP request method
httpProcessor.parseRequest.read=Missing HTTP request line
httpProcessor.parseRequest.uri=Missing HTTP request URI
+httpProcessor.parseHeaders.unknownExpectation=Unknown expectation header
httpProcessor.start=HTTP processor has already been started
httpProcessor.starting=Starting background thread
httpProcessor.stopping=Stopping background thread