You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Preston L. Bannister" <pr...@home.com> on 1999/12/27 18:14:57 UTC
Patch to (better) support running Tomcat on EBCDIC systems.
With the following patch, Tomcat comes up and presents at least the first few example pages.
Without the patch, Tomcat reads the "GET /" request as though it were EBCDIC (it is always ASCII) and rejects the request.
There are still other problems (like /examples/servlet/HelloWorldExample apparently sends EBCDIC :), but this is a start.
This patch should be entirely harmless on ASCII systems.
There are a few cases (in the connectors in particular) where perhaps the encoding should be UTF8? Someone more familiar with that
code should make the call (between ISO-8859-1 and UTF8 - not to reject the patch unless it's *really* wrong :).
I am a bit disturbed by the many conversions from byte[] to String. Seems like this should be all in one place (and perhaps create
less garbage) - but that is for another day :).
Index: src/share/org/apache/tomcat/core/BufferedServletInputStream.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletInputStream.java,v
retrieving revision 1.2
diff -u -b -r1.2 BufferedServletInputStream.java
--- BufferedServletInputStream.java 1999/10/29 23:40:44 1.2
+++ BufferedServletInputStream.java 1999/12/27 16:55:37
@@ -150,6 +150,10 @@
}
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
/**
* @deprecated Not part of Servlet API, without it we can avoid a lot of GC.
@@ -164,7 +168,7 @@
byte[] buf = new byte[1024];
int count = readLine(buf, 0, buf.length);
if (count >= 0) {
- return new String(buf, 0, count);
+ return new String(buf, 0, count, encoding);
} else {
return "";
}
Index: src/share/org/apache/tomcat/core/Request.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
retrieving revision 1.8
diff -u -b -r1.8 Request.java
--- Request.java 1999/11/03 20:38:52 1.8
+++ Request.java 1999/12/27 16:55:37
@@ -553,10 +553,15 @@
RequestUtil.processFormData( data, parameters );
}
- public void processFormData(InputStream in, int contentLength) {
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
+ public void processFormData(InputStream in, int contentLength) throws UnsupportedEncodingException {
byte[] buf = new byte[contentLength]; // XXX garbage collection!
int read = RequestUtil.readData( in, buf, contentLength );
- String s = new String(buf, 0, read);
+ String s = new String(buf, 0, read, encoding);
processFormData(s);
}
Index: src/share/org/apache/tomcat/core/ResponseAdapterImpl.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseAdapterImpl.java,v
retrieving revision 1.1
diff -u -b -r1.1 ResponseAdapterImpl.java
--- ResponseAdapterImpl.java 1999/11/01 20:09:22 1.1
+++ ResponseAdapterImpl.java 1999/12/27 16:55:37
@@ -129,13 +129,17 @@
return sos;
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
/** Write a chunk of bytes. Should be called only from ServletOutputStream implementations,
* No need to implement it if your adapter implements ServletOutputStream.
* Headers and status will be written before this method is exceuted.
*/
public void doWrite( byte buffer[], int pos, int count) throws IOException {
- body.append(new String(buffer, pos, count) );
+ body.append(new String(buffer, pos, count, encoding) );
}
public void recycle() {
Index: src/share/org/apache/tomcat/server/HttpRequestAdapter.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/server/HttpRequestAdapter.java,v
retrieving revision 1.2
diff -u -b -r1.2 HttpRequestAdapter.java
--- HttpRequestAdapter.java 1999/10/29 23:40:49 1.2
+++ HttpRequestAdapter.java 1999/12/27 16:55:39
@@ -106,6 +106,11 @@
return sin.read(b, off, len);
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public void readNextRequest(Response response) throws IOException {
String line="";
// cut&paste from BufferedInputStream.
@@ -113,7 +118,7 @@
byte[] buf = new byte[1024];
int count = in.readLine(buf, 0, buf.length);
if (count >= 0) {
- line=new String(buf, 0, count);
+ line=new String(buf, 0, count, encoding);
}
processRequestLine(response,line);
Index: src/share/org/apache/tomcat/service/Ajp11ConnectionHandler.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/Ajp11ConnectionHandler.java,v
retrieving revision 1.9
diff -u -b -r1.9 Ajp11ConnectionHandler.java
--- Ajp11ConnectionHandler.java 1999/11/01 22:24:14 1.9
+++ Ajp11ConnectionHandler.java 1999/12/27 16:55:39
@@ -216,6 +216,11 @@
class Ajp11 {
public static final int CH_REQUEST_DATA=1;
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public static void readAJPData(InputStream in, Hashtable env_vars, MimeHeaders headers ) throws IOException {
byte id = 0;
int index = 0;
@@ -252,7 +257,7 @@
// Read len bytes from the input stream
int len1=in.read(line, 0, len);
if ( len1 != len) {
- System.out.println( "REQUEST: " + new String(line, 0, len) );
+ System.out.println( "REQUEST: " + new String(line, 0, len, encoding) );
throw new IOException("Malformed AJP request: error reading line data " + len1 + " " + len);
}
@@ -264,9 +269,9 @@
// All id's take one or two pieces of data separated by a tab (09).
for (index = 1; (index < len) && (line[index] != 9); index++);
- token1 = new String(line, 1, index - 1);
+ token1 = new String(line, 1, index - 1, encoding);
if (index != len) {
- token2 = new String(line, index + 1, len - index - 1);
+ token2 = new String(line, index + 1, len - index - 1, encoding);
} else {
token2 = "";
}
Index: src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java,v
retrieving revision 1.4
diff -u -b -r1.4 Ajp12ConnectionHandler.java
--- Ajp12ConnectionHandler.java 1999/12/13 23:39:32 1.4
+++ Ajp12ConnectionHandler.java 1999/12/27 16:55:40
@@ -340,6 +340,11 @@
return ((int)((b1 << 8) | b2)) & 0xffff;
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public String readString(String def) throws java.io.IOException {
int len = readWord();
@@ -359,8 +364,6 @@
}
p = p+r;
}
- return new String(b);
+ return new String(b, encoding);
}
}
-
-
Index: src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java,v
retrieving revision 1.2
diff -u -b -r1.2 HttpRequestAdapter.java
--- HttpRequestAdapter.java 1999/12/17 05:14:03 1.2
+++ HttpRequestAdapter.java 1999/12/27 16:55:41
@@ -104,6 +104,11 @@
return sin.read(b, off, len);
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public void readNextRequest(Response response) throws IOException {
String line="";
// cut&paste from BufferedInputStream.
@@ -111,7 +116,7 @@
byte[] buf = new byte[Constants.RequestBufferSize];
int count = in.readLine(buf, 0, buf.length);
if (count >= 0) {
- line=new String(buf, 0, count);
+ line=new String(buf, 0, count, encoding);
}
processRequestLine(response,line);
Index: src/share/org/apache/tomcat/util/BuffTool.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/util/BuffTool.java,v
retrieving revision 1.2
diff -u -b -r1.2 BuffTool.java
--- BuffTool.java 1999/11/09 23:18:50 1.2
+++ BuffTool.java 1999/12/27 16:55:41
@@ -103,12 +103,17 @@
return (b1<<8) + (b2<<0);
}
- public static String getString( byte b[] , int pos, int len ) {
- return new String( b, pos, len );
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
+ public static String getString( byte b[] , int pos, int len ) throws UnsupportedEncodingException {
+ return new String( b, pos, len, encoding );
}
- public static void dump( byte buff[], int len ) {
+ public static void dump( byte buff[], int len ) throws UnsupportedEncodingException {
for (int i=0; i<len; i+=8 ) {
for(int j=i; j<i+8; j++ ) {
if( j<len) {
@@ -117,9 +122,9 @@
}
}
if( i+8 <len )
- System.out.print( new String( buff, i, 8 ));
+ System.out.print( new String( buff, i, 8, encoding ));
else
- System.out.print( new String( buff, i, len-i ));
+ System.out.print( new String( buff, i, len-i, encoding ));
System.out.println();
}
System.out.println();
Index: src/share/org/apache/tomcat/util/HttpDate.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/util/HttpDate.java,v
retrieving revision 1.1.1.1
diff -u -b -r1.1.1.1 HttpDate.java
--- HttpDate.java 1999/10/09 00:20:56 1.1.1.1
+++ HttpDate.java 1999/12/27 16:55:41
@@ -168,10 +168,15 @@
}
}
- public void parse(byte[] b, int off, int len) {
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
+ public void parse(byte[] b, int off, int len) throws java.io.UnsupportedEncodingException {
// ok -- so this is pretty stoopid, but the old version of this
// source took this arg set, so we will too for now (backwards compat)
- String dateString = new String(b, off, len);
+ String dateString = new String(b, off, len, encoding);
parse(dateString);
}
Index: src/share/org/apache/tomcat/util/MessageBytes.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java,v
retrieving revision 1.1.1.1
diff -u -b -r1.1.1.1 MessageBytes.java
--- MessageBytes.java 1999/10/09 00:20:56 1.1.1.1
+++ MessageBytes.java 1999/12/27 16:55:41
@@ -169,11 +169,20 @@
return bytes != null;
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
/**
* Returns the message bytes as a String object.
*/
public String toString() {
- return bytes != null ? new String(bytes, offset, length) : null;
+ try {
+ return bytes != null ? new String(bytes, offset, length, encoding) : null;
+ } catch (java.io.UnsupportedEncodingException e) {
+ return null; // could return something - but why?
+ }
}
/**
@@ -189,7 +198,7 @@
* @param d the HttpDate object to use for parsing
* @exception IllegalArgumentException if the date format was invalid
*/
- public long toDate(HttpDate d) throws IllegalArgumentException {
+ public long toDate(HttpDate d) throws IllegalArgumentException, java.io.UnsupportedEncodingException {
if (bytes != null) {
d.parse(bytes, offset, length);
return d.getTime();
Index: src/tests/share/tests/perf/CounterClient.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/tests/share/tests/perf/CounterClient.java,v
retrieving revision 1.2
diff -u -b -r1.2 CounterClient.java
--- CounterClient.java 1999/10/14 23:49:00 1.2
+++ CounterClient.java 1999/12/27 16:55:45
@@ -38,6 +38,11 @@
private static final int Iterations = 1000;
private static final boolean Debug = true;
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public String getDescription() {
return "serlvet ping test";
}
@@ -128,7 +133,7 @@
try {
in.read(b);
- count = Integer.parseInt(new String(b).trim());
+ count = Integer.parseInt(new String(b,encoding).trim());
} catch (IOException ioe) {
if (this.Debug) {
ioe.printStackTrace();
@@ -183,7 +188,7 @@
try {
in.read(b);
- count = Integer.parseInt(new String(b).trim());
+ count = Integer.parseInt(new String(b,encoding).trim());
} catch (IOException ioe) {
if (this.Debug) {
ioe.printStackTrace();
[PATCH] Better support for running Tomcat on EBCDIC systems.
Posted by "Preston L. Bannister" <pr...@home.com>.
The following patch gets Tomcat to run all the servlet (but not JSP) examples correctly.
This patch includes the previous patch for EBCDIC. Without the patch, Tomcat reads the "GET /" request as though it were EBCDIC (it
is always ASCII) and rejects the request. There are still other problems (like all the JSP examples :), but this is a start.
This patch should be entirely harmless on ASCII systems.
There are a few cases (in the connectors in particular) where perhaps the encoding should be UTF8? Someone more familiar with that
code should make the call (between ISO-8859-1 and UTF8 - not to reject the patch unless it's *really* wrong :).
I am a bit disturbed by the many conversions from byte[] to String. Seems like this should be all in one place (and perhaps create
less garbage) - but that is for another day :).
Also, I am running up against an issue:
What encoding should be used for editable text files?
I've gotten this far by leaving all the text files (*.java, *.jsp, *.xml, *.dtd, etc.) as ASCII. This makes them rather difficult
to edit or view on an EBCDIC system. If I translate all the text files to EBCDIC (as I did on a previous attempt) the load of the
XML configuration ... well, in short it screws up royally.
Ideally I think that text files that you would normally consider editing or viewing should be in the native character set (i.e.
EBCDIC on EBCDIC systems), but for the moment this is simply too much work. I would suggest that instead the text files be assumed
to always be ASCII or UTF8 (as appropriate) rather than the value suggested by "file.encoding".
This requires some explicit code to work on EBCDIC systems, but should not effect native ASCII boxes.
Opinions??
Another point is "// XXX" style comments that I've used to flag possible EBCDIC issues. Should these also be committed to CVS? I
may not get to them all, and this would help out the next guy to come along...
Index: src/share/javax/servlet/http/HttpUtils.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/javax/servlet/http/HttpUtils.java,v
retrieving revision 1.3
diff -u -b -r1.3 HttpUtils.java
--- HttpUtils.java 1999/11/08 03:21:39 1.3
+++ HttpUtils.java 1999/12/27 19:45:17
@@ -87,8 +87,13 @@
static Hashtable nullHashtable = new Hashtable();
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
/**
* Constructs an empty <code>HttpUtils</code> object.
*
@@ -211,8 +216,10 @@
*/
- static public Hashtable parsePostData(int len,
- ServletInputStream in)
+ static public Hashtable parsePostData(
+ int len,
+ ServletInputStream in
+ ) throws java.io.UnsupportedEncodingException
{
int inputLen, offset;
byte[] postedBytes = null;
@@ -252,7 +259,7 @@
// that the body should always be treated as FORM data.
//
- postedBody = new String(postedBytes, 0, len);
+ postedBody = new String(postedBytes, 0, len, encoding);
return parseQueryString(postedBody);
}
Index: src/share/org/apache/jasper/compiler/JspReader.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v
retrieving revision 1.6
diff -u -b -r1.6 JspReader.java
--- JspReader.java 1999/12/21 13:14:16 1.6
+++ JspReader.java 1999/12/27 19:45:19
@@ -143,7 +143,7 @@
encoding = System.getProperty("file.encoding", "8859_1");
// Register the file, and read its content:
int fileid = registerSourceFile(file.getAbsolutePath());
- Reader reader = null;
+ InputStreamReader reader = null;
try {
if (context == null)
reader = new InputStreamReader(new FileInputStream(file),
@@ -166,6 +166,9 @@
}
}
+ // XXX - EBCDIC issue here?
+ System.out.println("org.apache.jasper.compiler.JspReader.pushFile reader.getEncoding() \"" + reader.getEncoding() +
"\"");
+
CharArrayWriter caw = new CharArrayWriter();
char buf[] = new char[1024];
for (int i = 0 ; (i = reader.read(buf)) != -1 ; )
Index: src/share/org/apache/tomcat/core/BufferedServletInputStream.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletInputStream.java,v
retrieving revision 1.2
diff -u -b -r1.2 BufferedServletInputStream.java
--- BufferedServletInputStream.java 1999/10/29 23:40:44 1.2
+++ BufferedServletInputStream.java 1999/12/27 19:45:20
@@ -150,6 +150,10 @@
}
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
/**
* @deprecated Not part of Servlet API, without it we can avoid a lot of GC.
@@ -164,7 +168,7 @@
byte[] buf = new byte[1024];
int count = readLine(buf, 0, buf.length);
if (count >= 0) {
- return new String(buf, 0, count);
+ return new String(buf, 0, count, encoding);
} else {
return "";
}
Index: src/share/org/apache/tomcat/core/Request.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
retrieving revision 1.8
diff -u -b -r1.8 Request.java
--- Request.java 1999/11/03 20:38:52 1.8
+++ Request.java 1999/12/27 19:45:20
@@ -553,10 +553,15 @@
RequestUtil.processFormData( data, parameters );
}
- public void processFormData(InputStream in, int contentLength) {
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
+ public void processFormData(InputStream in, int contentLength) throws UnsupportedEncodingException {
byte[] buf = new byte[contentLength]; // XXX garbage collection!
int read = RequestUtil.readData( in, buf, contentLength );
- String s = new String(buf, 0, read);
+ String s = new String(buf, 0, read, encoding);
processFormData(s);
}
Index: src/share/org/apache/tomcat/core/Response.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
retrieving revision 1.5
diff -u -b -r1.5 Response.java
--- Response.java 1999/12/21 03:15:20 1.5
+++ Response.java 1999/12/27 19:45:20
@@ -88,9 +88,11 @@
protected Vector systemCookies = new Vector();
protected String contentType = Constants.ContentType.Default;
protected String contentLanguage = null;
- protected String characterEncoding =
- System.getProperty("file.encoding",
- Constants.CharacterEncoding.Default);
+ protected String characterEncoding = Constants.CharacterEncoding.Default;
+ // XXX - This is wrong, at least for EBCDIC systems, and likely for all?
+ //protected String characterEncoding =
+ // System.getProperty("file.encoding",
+ // Constants.CharacterEncoding.Default);
protected int contentLength = -1;
protected int status = 200;
private Locale locale = new Locale(Constants.Locale.Default, "");
@@ -223,6 +225,9 @@
if (writer == null) {
String encoding = getCharacterEncoding();
+ // XXX - EBCDIC issue here?
+ System.out.println("org.apache.tomcat.core.Response.getWriter encoding \"" + encoding + "\"");
+
if ((encoding == null) || "Default".equals(encoding) )
writer = new PrintWriter(new OutputStreamWriter(out));
else
@@ -237,7 +242,7 @@
// Deal with strange encodings - webmaster should see a message
// and install encoding classes - n new, unknown language was discovered,
// and they read our site!
- System.out.println("Unsuported encoding: " + encoding );
+ System.out.println("Unsupported encoding: " + encoding );
}
}
Index: src/share/org/apache/tomcat/core/ResponseAdapterImpl.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseAdapterImpl.java,v
retrieving revision 1.1
diff -u -b -r1.1 ResponseAdapterImpl.java
--- ResponseAdapterImpl.java 1999/11/01 20:09:22 1.1
+++ ResponseAdapterImpl.java 1999/12/27 19:45:20
@@ -129,13 +129,17 @@
return sos;
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
/** Write a chunk of bytes. Should be called only from ServletOutputStream implementations,
* No need to implement it if your adapter implements ServletOutputStream.
* Headers and status will be written before this method is exceuted.
*/
public void doWrite( byte buffer[], int pos, int count) throws IOException {
- body.append(new String(buffer, pos, count) );
+ body.append(new String(buffer, pos, count, encoding) );
}
public void recycle() {
Index: src/share/org/apache/tomcat/server/HttpRequestAdapter.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/server/HttpRequestAdapter.java,v
retrieving revision 1.2
diff -u -b -r1.2 HttpRequestAdapter.java
--- HttpRequestAdapter.java 1999/10/29 23:40:49 1.2
+++ HttpRequestAdapter.java 1999/12/27 19:45:23
@@ -106,6 +106,11 @@
return sin.read(b, off, len);
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public void readNextRequest(Response response) throws IOException {
String line="";
// cut&paste from BufferedInputStream.
@@ -113,7 +118,7 @@
byte[] buf = new byte[1024];
int count = in.readLine(buf, 0, buf.length);
if (count >= 0) {
- line=new String(buf, 0, count);
+ line=new String(buf, 0, count, encoding);
}
processRequestLine(response,line);
Index: src/share/org/apache/tomcat/service/Ajp11ConnectionHandler.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/Ajp11ConnectionHandler.java,v
retrieving revision 1.9
diff -u -b -r1.9 Ajp11ConnectionHandler.java
--- Ajp11ConnectionHandler.java 1999/11/01 22:24:14 1.9
+++ Ajp11ConnectionHandler.java 1999/12/27 19:45:23
@@ -216,6 +216,11 @@
class Ajp11 {
public static final int CH_REQUEST_DATA=1;
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public static void readAJPData(InputStream in, Hashtable env_vars, MimeHeaders headers ) throws IOException {
byte id = 0;
int index = 0;
@@ -252,7 +257,7 @@
// Read len bytes from the input stream
int len1=in.read(line, 0, len);
if ( len1 != len) {
- System.out.println( "REQUEST: " + new String(line, 0, len) );
+ System.out.println( "REQUEST: " + new String(line, 0, len, encoding) );
throw new IOException("Malformed AJP request: error reading line data " + len1 + " " + len);
}
@@ -264,9 +269,9 @@
// All id's take one or two pieces of data separated by a tab (09).
for (index = 1; (index < len) && (line[index] != 9); index++);
- token1 = new String(line, 1, index - 1);
+ token1 = new String(line, 1, index - 1, encoding);
if (index != len) {
- token2 = new String(line, index + 1, len - index - 1);
+ token2 = new String(line, index + 1, len - index - 1, encoding);
} else {
token2 = "";
}
Index: src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java,v
retrieving revision 1.4
diff -u -b -r1.4 Ajp12ConnectionHandler.java
--- Ajp12ConnectionHandler.java 1999/12/13 23:39:32 1.4
+++ Ajp12ConnectionHandler.java 1999/12/27 19:45:23
@@ -340,6 +340,11 @@
return ((int)((b1 << 8) | b2)) & 0xffff;
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public String readString(String def) throws java.io.IOException {
int len = readWord();
@@ -359,8 +364,6 @@
}
p = p+r;
}
- return new String(b);
+ return new String(b, encoding);
}
}
-
-
Index: src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java,v
retrieving revision 1.2
diff -u -b -r1.2 HttpRequestAdapter.java
--- HttpRequestAdapter.java 1999/12/17 05:14:03 1.2
+++ HttpRequestAdapter.java 1999/12/27 19:45:24
@@ -104,6 +104,11 @@
return sin.read(b, off, len);
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public void readNextRequest(Response response) throws IOException {
String line="";
// cut&paste from BufferedInputStream.
@@ -111,7 +116,7 @@
byte[] buf = new byte[Constants.RequestBufferSize];
int count = in.readLine(buf, 0, buf.length);
if (count >= 0) {
- line=new String(buf, 0, count);
+ line=new String(buf, 0, count, encoding);
}
processRequestLine(response,line);
Index: src/share/org/apache/tomcat/util/BuffTool.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/util/BuffTool.java,v
retrieving revision 1.2
diff -u -b -r1.2 BuffTool.java
--- BuffTool.java 1999/11/09 23:18:50 1.2
+++ BuffTool.java 1999/12/27 19:45:24
@@ -103,12 +103,17 @@
return (b1<<8) + (b2<<0);
}
- public static String getString( byte b[] , int pos, int len ) {
- return new String( b, pos, len );
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
+ public static String getString( byte b[] , int pos, int len ) throws UnsupportedEncodingException {
+ return new String( b, pos, len, encoding );
}
- public static void dump( byte buff[], int len ) {
+ public static void dump( byte buff[], int len ) throws UnsupportedEncodingException {
for (int i=0; i<len; i+=8 ) {
for(int j=i; j<i+8; j++ ) {
if( j<len) {
@@ -117,9 +122,9 @@
}
}
if( i+8 <len )
- System.out.print( new String( buff, i, 8 ));
+ System.out.print( new String( buff, i, 8, encoding ));
else
- System.out.print( new String( buff, i, len-i ));
+ System.out.print( new String( buff, i, len-i, encoding ));
System.out.println();
}
System.out.println();
Index: src/share/org/apache/tomcat/util/HttpDate.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/util/HttpDate.java,v
retrieving revision 1.1.1.1
diff -u -b -r1.1.1.1 HttpDate.java
--- HttpDate.java 1999/10/09 00:20:56 1.1.1.1
+++ HttpDate.java 1999/12/27 19:45:24
@@ -168,10 +168,15 @@
}
}
- public void parse(byte[] b, int off, int len) {
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
+ public void parse(byte[] b, int off, int len) throws java.io.UnsupportedEncodingException {
// ok -- so this is pretty stoopid, but the old version of this
// source took this arg set, so we will too for now (backwards compat)
- String dateString = new String(b, off, len);
+ String dateString = new String(b, off, len, encoding);
parse(dateString);
}
Index: src/share/org/apache/tomcat/util/MessageBytes.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java,v
retrieving revision 1.1.1.1
diff -u -b -r1.1.1.1 MessageBytes.java
--- MessageBytes.java 1999/10/09 00:20:56 1.1.1.1
+++ MessageBytes.java 1999/12/27 19:45:24
@@ -169,11 +169,20 @@
return bytes != null;
}
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
/**
* Returns the message bytes as a String object.
*/
public String toString() {
- return bytes != null ? new String(bytes, offset, length) : null;
+ try {
+ return bytes != null ? new String(bytes, offset, length, encoding) : null;
+ } catch (java.io.UnsupportedEncodingException e) {
+ return null; // could return something - but why?
+ }
}
/**
@@ -189,7 +198,7 @@
* @param d the HttpDate object to use for parsing
* @exception IllegalArgumentException if the date format was invalid
*/
- public long toDate(HttpDate d) throws IllegalArgumentException {
+ public long toDate(HttpDate d) throws IllegalArgumentException, java.io.UnsupportedEncodingException {
if (bytes != null) {
d.parse(bytes, offset, length);
Index: src/tests/share/tests/perf/CounterClient.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/tests/share/tests/perf/CounterClient.java,v
retrieving revision 1.2
diff -u -b -r1.2 CounterClient.java
--- CounterClient.java 1999/10/14 23:49:00 1.2
+++ CounterClient.java 1999/12/27 19:45:27
@@ -38,6 +38,11 @@
private static final int Iterations = 1000;
private static final boolean Debug = true;
+ // XXX Temporary fix for encoding
+ // Any reason this should be a soft setting?
+ final static String encoding = "ISO-8859-1"; // as called for by HTTP standard?
+ // final static String encoding = "UTF8"; // more useful?
+
public String getDescription() {
return "serlvet ping test";
}
@@ -128,7 +133,7 @@
try {
in.read(b);
- count = Integer.parseInt(new String(b).trim());
+ count = Integer.parseInt(new String(b,encoding).trim());
} catch (IOException ioe) {
if (this.Debug) {
ioe.printStackTrace();
@@ -183,7 +188,7 @@
try {
in.read(b);
- count = Integer.parseInt(new String(b).trim());
+ count = Integer.parseInt(new String(b,encoding).trim());
} catch (IOException ioe) {
if (this.Debug) {
--
Preston L. Bannister
http://members.home.com/preston
preston@home.com