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...@apache.org on 2002/03/09 06:20:03 UTC
cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters IdentityInputFilter.java IdentityOutputFilter.java
remm 02/03/08 21:20:03
Modified: http11/src/java/org/apache/coyote/http11
Http11Processor.java InternalInputBuffer.java
http11/src/java/org/apache/coyote/http11/filters
IdentityInputFilter.java IdentityOutputFilter.java
Log:
- Add HTTP/0.9 support.
- Make the identity OF handle the case where the content length is 0.
- Make the calculation of the number of bytes written more robust in the identity filters.
Revision Changes Path
1.5 +10 -19 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java
Index: Http11Processor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Http11Processor.java 9 Mar 2002 04:39:21 -0000 1.4
+++ Http11Processor.java 9 Mar 2002 05:20:03 -0000 1.5
@@ -169,6 +169,12 @@
/**
+ * HTTP/0.9 flag.
+ */
+ protected boolean http09 = false;
+
+
+ /**
* Content delimitator for the request (if false, the connection will
* be closed at the end of the request).
*/
@@ -431,6 +437,7 @@
protected void prepareRequest() {
http11 = true;
+ http09 = false;
contentDelimitation = false;
MessageBytes protocolMB = request.protocol();
@@ -441,6 +448,7 @@
keepAlive = false;
} else if (protocolMB.equals("")) {
// HTTP/0.9
+ http09 = true;
http11 = false;
keepAlive = false;
} else {
@@ -498,15 +506,10 @@
// Parse content-length header
int contentLength = request.getContentLength();
- if (contentLength > 0) {
+ if (contentLength >= 0) {
inputBuffer.addActiveFilter
(inputFilters[Constants.IDENTITY_FILTER]);
contentDelimitation = true;
- } else if (contentLength == 0) {
- // No content to read
- inputBuffer.addActiveFilter
- (inputFilters[Constants.VOID_FILTER]);
- contentDelimitation = true;
}
// Parse transfer-encoding header
@@ -550,12 +553,6 @@
}
if (!contentDelimitation) {
- /*
- // If method is GET or HEAD, prevent from reading any content
- if ((methodMB.equals("GET"))
- || (methodMB.equals("HEAD"))
- || (methodMB.equals("TRACE"))) {
- */
// If there's no content length and we're using HTTP/1.1, assume
// the client is not broken and didn't send a body
if (http11) {
@@ -577,18 +574,12 @@
*/
protected void prepareResponse() {
- boolean http09 = false;
boolean entityBody = true;
contentDelimitation = false;
OutputFilter[] outputFilters = outputBuffer.getFilters();
- MessageBytes protocolMB = request.protocol();
- if (protocolMB.equals(Constants.HTTP_11)) {
- http11 = true;
- } else if (protocolMB.equals(Constants.HTTP_10)) {
- http11 = false;
- } else if (protocolMB.equals("")) {
+ if (http09 == true) {
// HTTP/0.9
outputBuffer.addActiveFilter
(outputFilters[Constants.IDENTITY_FILTER]);
1.10 +8 -4 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalInputBuffer.java
Index: InternalInputBuffer.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalInputBuffer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- InternalInputBuffer.java 10 Jan 2002 15:30:38 -0000 1.9
+++ InternalInputBuffer.java 9 Mar 2002 05:20:03 -0000 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalInputBuffer.java,v 1.9 2002/01/10 15:30:38 remm Exp $
- * $Revision: 1.9 $
- * $Date: 2002/01/10 15:30:38 $
+ * $Header: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalInputBuffer.java,v 1.10 2002/03/09 05:20:03 remm Exp $
+ * $Revision: 1.10 $
+ * $Date: 2002/03/09 05:20:03 $
*
* ====================================================================
*
@@ -506,7 +506,11 @@
}
- request.protocol().setBytes(buf, start, end - start);
+ if ((end - start) > 0) {
+ request.protocol().setBytes(buf, start, end - start);
+ } else {
+ request.protocol().setString("");
+ }
}
1.8 +2 -4 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityInputFilter.java
Index: IdentityInputFilter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityInputFilter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- IdentityInputFilter.java 10 Jan 2002 15:45:32 -0000 1.7
+++ IdentityInputFilter.java 9 Mar 2002 05:20:03 -0000 1.8
@@ -151,9 +151,9 @@
public int doRead(ByteChunk chunk)
throws IOException {
- int result = 0;
+ int result = -1;
- if (contentLength > 0) {
+ if (contentLength >= 0) {
if (remaining > 0) {
int nRead = buffer.doRead(chunk);
if (nRead > remaining) {
@@ -173,8 +173,6 @@
chunk.recycle();
result = -1;
}
- } else {
- result = buffer.doRead(chunk);
}
return result;
1.5 +6 -2 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityOutputFilter.java
Index: IdentityOutputFilter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityOutputFilter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IdentityOutputFilter.java 11 Jan 2002 23:56:07 -0000 1.4
+++ IdentityOutputFilter.java 9 Mar 2002 05:20:03 -0000 1.5
@@ -141,9 +141,9 @@
public int doWrite(ByteChunk chunk)
throws IOException {
- int result = 0;
+ int result = -1;
- if (contentLength > 0) {
+ if (contentLength >= 0) {
if (remaining > 0) {
result = chunk.getLength();
if (result > remaining) {
@@ -164,6 +164,10 @@
chunk.recycle();
result = -1;
}
+ } else {
+ // If no content length was set, just write the bytes
+ buffer.doWrite(chunk);
+ result = chunk.getLength();
}
return result;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>