Author: remy.maucherat(a)jboss.com
Date: 2008-09-29 11:28:37 -0400 (Mon, 29 Sep 2008)
New Revision: 795
Modified:
trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
trunk/java/org/apache/coyote/ajp/AjpProcessor.java
trunk/java/org/apache/tomcat/util/http/ServerCookie.java
trunk/webapps/docs/changelog.xml
Log:
- Two minor AJP fixes.
- Remove usage of DateTool in ServerCookie (bad syncs).
Modified: trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
===================================================================
--- trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java 2008-09-27 18:50:25 UTC (rev
794)
+++ trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java 2008-09-29 15:28:37 UTC (rev
795)
@@ -95,6 +95,17 @@
inputBuffer.limit(0);
outputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
+ // Set the get body message buffer
+ AjpMessage getBodyMessage = new AjpMessage(16);
+ getBodyMessage.reset();
+ getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
+ getBodyMessage.appendInt(packetSize - Constants.READ_HEAD_LEN);
+ getBodyMessage.end();
+ getBodyMessageBuffer =
+ ByteBuffer.allocateDirect(getBodyMessage.getLen());
+ getBodyMessageBuffer.put(getBodyMessage.getBuffer(), 0,
+ getBodyMessage.getLen());
+
// Cause loading of HexUtils
int foo = HexUtils.DEC[0];
@@ -238,7 +249,7 @@
/**
* Direct buffer used for sending right away a get body message.
*/
- protected static final ByteBuffer getBodyMessageBuffer;
+ protected final ByteBuffer getBodyMessageBuffer;
/**
@@ -263,17 +274,6 @@
static {
- // Set the get body message buffer
- AjpMessage getBodyMessage = new AjpMessage(16);
- getBodyMessage.reset();
- getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
- getBodyMessage.appendInt(Constants.MAX_READ_SIZE);
- getBodyMessage.end();
- getBodyMessageBuffer =
- ByteBuffer.allocateDirect(getBodyMessage.getLen());
- getBodyMessageBuffer.put(getBodyMessage.getBuffer(), 0,
- getBodyMessage.getLen());
-
// Set the read body message buffer
AjpMessage pongMessage = new AjpMessage(16);
pongMessage.reset();
@@ -924,6 +924,10 @@
} else {
message = message.replace('\n', ' ').replace('\r',
' ');
}
+ if (message == null) {
+ // Many httpd 2.x wants a non empty status message
+ message = Integer.toString(response.getStatus());
+ }
tmpMB.setString(message);
responseHeaderMessage.appendBytes(tmpMB);
Modified: trunk/java/org/apache/coyote/ajp/AjpProcessor.java
===================================================================
--- trunk/java/org/apache/coyote/ajp/AjpProcessor.java 2008-09-27 18:50:25 UTC (rev 794)
+++ trunk/java/org/apache/coyote/ajp/AjpProcessor.java 2008-09-29 15:28:37 UTC (rev 795)
@@ -90,6 +90,16 @@
responseHeaderMessage = new AjpMessage(packetSize);
bodyMessage = new AjpMessage(packetSize);
+ // Set the get body message buffer
+ AjpMessage getBodyMessage = new AjpMessage(16);
+ getBodyMessage.reset();
+ getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
+ getBodyMessage.appendInt(packetSize - Constants.READ_HEAD_LEN);
+ getBodyMessage.end();
+ getBodyMessageArray = new byte[getBodyMessage.getLen()];
+ System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray,
+ 0, getBodyMessage.getLen());
+
// Cause loading of HexUtils
int foo = HexUtils.DEC[0];
@@ -240,7 +250,7 @@
/**
* Direct buffer used for sending right away a get body message.
*/
- protected static final byte[] getBodyMessageArray;
+ protected final byte[] getBodyMessageArray;
/**
@@ -265,17 +275,6 @@
static {
- // Set the get body message buffer
-
- AjpMessage getBodyMessage = new AjpMessage(16);
- getBodyMessage.reset();
- getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
- getBodyMessage.appendInt(Constants.MAX_READ_SIZE);
- getBodyMessage.end();
- getBodyMessageArray = new byte[getBodyMessage.getLen()];
- System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray,
- 0, getBodyMessage.getLen());
-
// Set the read body message buffer
AjpMessage pongMessage = new AjpMessage(16);
pongMessage.reset();
@@ -930,6 +929,10 @@
} else {
message = message.replace('\n', ' ').replace('\r',
' ');
}
+ if (message == null) {
+ // Many httpd 2.x wants a non empty status message
+ message = Integer.toString(response.getStatus());
+ }
tmpMB.setString(message);
responseHeaderMessage.appendBytes(tmpMB);
Modified: trunk/java/org/apache/tomcat/util/http/ServerCookie.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/ServerCookie.java 2008-09-27 18:50:25 UTC (rev
794)
+++ trunk/java/org/apache/tomcat/util/http/ServerCookie.java 2008-09-29 15:28:37 UTC (rev
795)
@@ -18,11 +18,13 @@
package org.apache.tomcat.util.http;
import java.io.Serializable;
+import java.text.DateFormat;
import java.text.FieldPosition;
+import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Locale;
import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.buf.DateTool;
import org.apache.tomcat.util.buf.MessageBytes;
@@ -245,9 +247,11 @@
}
}
- private static final String ancientDate =
- DateTool.formatOldCookie(new Date(10000));
+ private final static DateFormat oldCookieFormat =
+ new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss z", Locale.US);
+ private static final String ancientDate = oldCookieFormat.format(new Date(10000));
+
// TODO RFC2965 fields also need to be passed
public static void appendCookieValue( StringBuffer headerBuf,
int version,
@@ -293,14 +297,16 @@
// Wdy, DD-Mon-YY HH:MM:SS GMT ( Expires Netscape format )
buf.append ("; Expires=");
// To expire immediately we need to set the time in past
- if (maxAge == 0)
+ if (maxAge == 0) {
buf.append( ancientDate );
- else
- DateTool.formatOldCookie
+ } else {
+ synchronized(oldCookieFormat) {
+ oldCookieFormat.format
(new Date( System.currentTimeMillis() +
- maxAge *1000L), buf,
- new FieldPosition(0));
-
+ maxAge *1000L), buf,
+ new FieldPosition(0));
+ }
+ }
} else {
buf.append ("; Max-Age=");
buf.append (maxAge);
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-09-27 18:50:25 UTC (rev 794)
+++ trunk/webapps/docs/changelog.xml 2008-09-29 15:28:37 UTC (rev 795)
@@ -57,6 +57,16 @@
IntrospectionUtils.replaceProperties should return the original String if no
substitutions are
needed. (remm)
</fix>
+ <fix>
+ Sync date format usage for old cookies. (remm)
+ </fix>
+ <fix>
+ <bug>45026</bug>: AJP should not use an empty reason phrase, due to
httpd 2 having a problem
+ with that at the moment. (rjung)
+ </fix>
+ <fix>
+ Allow AJP to read large body packets, up to the configured packet size. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">