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 2000/01/06 17:07:07 UTC
[PATCH] EBCDIC support - partial JSP and cleanup
Got a bit further on EBCDIC support for Tomcat.
With the enclosed patch (against the current base in CVS) everything through some of the simpler JSP pages works on IBM OS/390.
Amusingly enough WebSphere 1.2 on OS/390 (which only supports an earlier version of JSP) does no better on the JSP examples. So I
guess I could claim Tomcat works as well as WebSphere on JSP :).
Also went back and cleaned up some of the earlier changes for EBCDIC support.
The tests in "build\tomcat\test\runtest" are just as successful on Win32 after these changes, so I don't think I've broken anything
:). There are two tests that fail with the sources currently in CVS, and the same two tests (and only those tests) still fail after
the patch.
I have not tried to run the tests on OS/390, as the tests have not been ported.
Most likely I won't get a chance to get back to this for at least a few weeks, so I would appreciate someone checking in this.
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 2000/01/06 15:35:18
@@ -252,9 +252,14 @@
// that the body should always be treated as FORM data.
//
- postedBody = new String(postedBytes, 0, len);
-
+ try {
+ postedBody = new String(postedBytes, 0, len, "8859_1");
return parseQueryString(postedBody);
+ } catch (java.io.UnsupportedEncodingException e) {
+ // XXX function should accept an encoding parameter & throw this exception.
+ // Otherwise throw something expected.
+ throw new IllegalArgumentException(e.getMessage());
+ }
}
Index: src/share/org/apache/jasper/compiler/Compiler.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v
retrieving revision 1.5
diff -u -b -r1.5 Compiler.java
--- Compiler.java 1999/12/28 16:25:54 1.5
+++ Compiler.java 2000/01/06 15:35:19
@@ -123,13 +123,31 @@
if (!isOutDated())
return false;
- JspReader reader = JspReader.createJspReader(ctxt.getJspFile(), ctxt.getServletContext());
+ // Need the encoding specified in the JSP 'page' directive for
+ // - reading the JSP page
+ // - writing the JSP servlet source
+ // - compiling the generated servlets (pass -encoding to javac).
+ // XXX - There are really three encodings of interest.
+
+ String jspEncoding = "8859_1"; // default per JSP spec
+ String javaEncoding = "UTF8"; // perhaps debatable?
+
+ //System.out.println("org.apache.jasper.compiler.Compiler.compile jspEncoding = \"" + jspEncoding + "\"");
+ //System.out.println("org.apache.jasper.compiler.Compiler.compile javaEncoding = \"" + javaEncoding + "\"");
+
+ JspReader reader = JspReader.createJspReader(
+ ctxt.getJspFile(),
+ ctxt.getServletContext(),
+ jspEncoding
+ );
ServletWriter writer =
- (new ServletWriter
- (new PrintWriter
- (new EscapeUnicodeWriter
- (new FileOutputStream(javaFileName)))));
+ new ServletWriter(
+ new PrintWriter(
+ new java.io.OutputStreamWriter(
+ new FileOutputStream(javaFileName),
+ javaEncoding
+ )));
ctxt.setReader(reader);
ctxt.setWriter(writer);
@@ -142,29 +160,8 @@
listener.endPageProcessing();
writer.close();
- // For compiling the generated servlets, you need to
- // pass -encoding to javac.
-
- String encoding = ctxt.getContentType();
String classpath = ctxt.getClassPath();
- // Pick up everything after ";charset="
- if (encoding != null) {
- int semi = encoding.indexOf(";");
- if (semi == -1)
- encoding = null;
- else {
- String afterSemi = encoding.substring(semi+1);
- int charsetLocation = afterSemi.indexOf("charset=");
- if (charsetLocation == -1)
- encoding = null;
- else {
- String afterCharset = afterSemi.substring(charsetLocation+8);
- encoding = afterCharset.trim();
- }
- }
- }
-
// I'm nuking
// System.getProperty("jsp.class.path", ".")
// business. If anyone badly needs this we can talk. -akv
@@ -172,6 +169,8 @@
String sep = System.getProperty("path.separator");
String[] argv = new String[]
{
+ "-encoding",
+ javaEncoding,
"-classpath",
System.getProperty("java.class.path")+ sep + classpath
+ sep + ctxt.getOutputDir(),
@@ -179,15 +178,6 @@
javaFileName
};
- if (encoding != null && !encoding.equals("")) {
- String[] args = new String[argv.length+2];
- args[0] = "-encoding";
- args[1] = encoding;
- for(int i = 0; i < argv.length; i++)
- args[i+2] = argv[i];
- argv = args;
- }
-
StringBuffer b = new StringBuffer();
for(int i = 0; i < argv.length; i++) {
b.append(argv[i]);
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.8
diff -u -b -r1.8 JspReader.java
--- JspReader.java 2000/01/04 02:53:05 1.8
+++ JspReader.java 2000/01/06 15:35:19
@@ -117,17 +117,19 @@
public void pushFile(String name, String encoding)
throws ParseException, FileNotFoundException
{
- String parent = master == null ?
- null : master.substring(0, master.lastIndexOf("/") + 1);
- boolean isAbsolute = name.startsWith("/");
-
- if (parent == null || isAbsolute)
- pushFile(new File(name), encoding);
- else
- pushFile(new File(parent + name), encoding);
+ //System.out.println("pushFile master = " + master + ", name = " + name + ", encoding = " + encoding);
- if (master == null)
+ if (null == master) {
master = name;
+ pushFile(new File(name),encoding);
+ return;
+ }
+ if (name.startsWith("/")) {
+ pushFile(new File(name),encoding);
+ return;
+ }
+ String parent = master.substring(0, master.lastIndexOf("/") + 1);
+ pushFile(new File(parent,name),encoding);
}
/**
@@ -138,12 +140,17 @@
private void pushFile(File file, String encoding)
throws ParseException, FileNotFoundException
{
- // Default encoding if needed:
- if (encoding == null)
- encoding = System.getProperty("file.encoding", "8859_1");
+ //System.out.println("org.apache.jasper.compiler.JspReader.pushFile file \"" + file.getAbsolutePath() + "\"");
+ //System.out.println("org.apache.jasper.compiler.JspReader.pushFile encoding \"" + encoding + "\"");
+
+ // If encoding not otherwise specified, assume ASCII.
+ if (null == encoding) {
+ 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),
@@ -160,7 +167,7 @@
throw new FileNotFoundException(fileName);
try {
- reader = new InputStreamReader(in);
+ reader = new InputStreamReader(in,encoding);
} catch (Throwable ex) {
throw new FileNotFoundException(fileName + ": "+ ex.getMessage());
}
@@ -194,7 +201,7 @@
}
public boolean popFile() {
- // Is stack created ? (will happen if the Jsp file we'r looking at is
+ // Is stack created ? (will happen if the Jsp file we're looking at is
// missing.
if (current == null)
return false;
@@ -205,17 +212,17 @@
return current.popStream();
}
- protected JspReader(String file, ServletContext ctx)
+ protected JspReader(String file, ServletContext ctx, String encoding)
throws ParseException, FileNotFoundException
{
this.context = ctx;
- pushFile(file, null);
+ pushFile(file, encoding);
}
- public static JspReader createJspReader(String file, ServletContext ctx)
+ public static JspReader createJspReader(String file, ServletContext ctx, String encoding)
throws ParseException, FileNotFoundException
{
- return new JspReader(file, ctx);
+ return new JspReader(file, ctx, encoding);
}
public boolean hasMoreInput() {
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 2000/01/06 15:35:19
@@ -164,7 +164,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, Constants.CharacterEncoding.Default);
} 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.10
diff -u -b -r1.10 Request.java
--- Request.java 2000/01/04 02:53:06 1.10
+++ Request.java 2000/01/06 15:35:19
@@ -253,7 +253,6 @@
if(charEncoding!=null) return charEncoding;
charEncoding=reqA.getCharacterEncoding();
if(charEncoding!=null) return charEncoding;
-
charEncoding = getCharsetFromContentType(getContentType());
return charEncoding;
}
@@ -457,9 +456,6 @@
public void setAuthType(String authType) {
this.authType = authType;
}
- public void setCharacterEncoding(String charEncoding) {
- this.charEncoding = charEncoding;
- }
public void setPathInfo(String pathInfo) {
@@ -614,10 +610,11 @@
RequestUtil.processFormData( data, parameters );
}
- public void processFormData(InputStream in, int contentLength) {
+ 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);
+ // XXX if charset is ever anything other than the default, this must be fixed.
+ String s = new String(buf, 0, read, Constants.CharacterEncoding.Default);
processFormData(s);
}
Index: src/share/org/apache/tomcat/core/RequestUtil.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestUtil.java,v
retrieving revision 1.4
diff -u -b -r1.4 RequestUtil.java
--- RequestUtil.java 1999/11/02 17:37:19 1.4
+++ RequestUtil.java 2000/01/06 15:35:19
@@ -151,10 +151,11 @@
String encoding = request.getCharacterEncoding();
if (encoding == null) {
// Set a default of Latin-1 even for non-Latin-1 systems
- encoding = "ISO-8859-1";
+ encoding = Constants.CharacterEncoding.Default;
}
InputStreamReader r =
new InputStreamReader(request.getInputStream(), encoding);
+
return new BufferedReader(r);
}
@@ -337,6 +338,7 @@
// Basically return everything after ";charset="
+ // If no charset specified, use the HTTP default (ASCII) character set.
public static String getCharsetFromContentType(String type) {
if (type == null) {
return null;
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 2000/01/06 15:35:19
@@ -88,9 +88,7 @@
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;
protected int contentLength = -1;
protected int status = 200;
private Locale locale = new Locale(Constants.Locale.Default, "");
@@ -163,8 +161,7 @@
systemCookies.removeAllElements();
contentType = Constants.ContentType.Default;
locale = new Locale(Constants.Locale.Default, "");
- characterEncoding = System.getProperty("file.encoding",
- Constants.CharacterEncoding.Default);
+ characterEncoding = Constants.CharacterEncoding.Default;
contentLength = -1;
status = 200;
headers.clear();
@@ -223,6 +220,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 +237,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 );
}
}
@@ -300,8 +300,7 @@
userCookies.removeAllElements(); // keep system (session) cookies
contentType = Constants.ContentType.Default;
locale = new Locale(Constants.Locale.Default, "");
- characterEncoding = System.getProperty("file.encoding",
- Constants.CharacterEncoding.Default);
+ characterEncoding = Constants.CharacterEncoding.Default;
contentLength = -1;
status = 200;
@@ -452,10 +451,7 @@
public void setContentType(String contentType) {
this.contentType = contentType;
- String encoding = RequestUtil.getCharsetFromContentType(contentType);
- if (encoding != null) {
- characterEncoding = encoding;
- }
+ characterEncoding = RequestUtil.getCharsetFromContentType(contentType);
}
public void setContentLength(int contentLength) {
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 2000/01/06 15:35:19
@@ -129,13 +129,13 @@
return sos;
}
-
/** 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) );
+ // XXX fix if charset is other than default.
+ body.append(new String(buffer, pos, count, Constants.CharacterEncoding.Default) );
}
public void recycle() {
Index: src/share/org/apache/tomcat/server/Constants.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/server/Constants.java,v
retrieving revision 1.3
diff -u -b -r1.3 Constants.java
--- Constants.java 1999/12/14 22:32:16 1.3
+++ Constants.java 2000/01/06 15:35:20
@@ -105,5 +105,9 @@
public static class Property {
public static final String Name = "server.properties";
public static final String ServerHeader = "server.header";
+ }
+
+ public static class CharacterEncoding {
+ public static final String Default = "8859_1";
}
}
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 2000/01/06 15:35:20
@@ -216,6 +216,9 @@
class Ajp11 {
public static final int CH_REQUEST_DATA=1;
+ // UTF8 is a strict superset of ASCII.
+ final static String CHARSET = "UTF8";
+
public static void readAJPData(InputStream in, Hashtable env_vars, MimeHeaders headers ) throws IOException {
byte id = 0;
int index = 0;
@@ -252,7 +255,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, CHARSET) );
throw new IOException("Malformed AJP request: error reading line data " + len1 + " " + len);
}
@@ -264,9 +267,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, CHARSET);
if (index != len) {
- token2 = new String(line, index + 1, len - index - 1);
+ token2 = new String(line, index + 1, len - index - 1, CHARSET);
} 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 2000/01/06 15:35:20
@@ -319,6 +319,9 @@
class Ajpv12InputStream extends BufferedInputStream {
+ // UTF8 is a strict superset of ASCII.
+ final static String CHARSET = "UTF8";
+
public Ajpv12InputStream(InputStream in) {
super(in);
}
@@ -359,8 +362,6 @@
}
p = p+r;
}
- return new String(b);
+ return new String(b, CHARSET);
}
}
-
-
Index: src/share/org/apache/tomcat/service/connector/MsgBuffer.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/MsgBuffer.java,v
retrieving revision 1.2
diff -u -b -r1.2 MsgBuffer.java
--- MsgBuffer.java 1999/11/11 23:28:13 1.2
+++ MsgBuffer.java 2000/01/06 15:35:20
@@ -157,7 +157,7 @@
return res;
}
- public String getString() {
+ public String getString() throws java.io.UnsupportedEncodingException {
int ll= getInt();
if( (ll == 0xFFFF) || (ll==-1) ) {
System.out.println("null string " + ll);
Index: src/share/org/apache/tomcat/service/http/Constants.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/http/Constants.java,v
retrieving revision 1.1
diff -u -b -r1.1 Constants.java
--- Constants.java 1999/12/17 05:14:03 1.1
+++ Constants.java 2000/01/06 15:35:20
@@ -71,4 +71,7 @@
public static final int RequestBufferSize = 2048;
+ public static class CharacterEncoding {
+ public static final String Default = "8859_1";
+ }
}
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 2000/01/06 15:35:20
@@ -111,7 +111,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, Constants.CharacterEncoding.Default);
}
processRequestLine(response,line);
Index: src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java,v
retrieving revision 1.2
diff -u -b -r1.2 HttpResponseAdapter.java
--- HttpResponseAdapter.java 1999/11/22 18:36:44 1.2
+++ HttpResponseAdapter.java 2000/01/06 15:35:20
@@ -87,14 +87,6 @@
protected StringBuffer statusSB;
protected StringBuffer headersSB;
- // XXX Temporary fix for encoding - it should be at a higher level
- // ( i.e. connector)
- // Also, we need to resolve few other problems in this are - header
- // encoding != body encoding, default should _not_ be platform def., etc.
- // 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 HttpResponseAdapter() {
super();
statusSB=new StringBuffer();
@@ -112,7 +104,7 @@
statusSB.append("HTTP/1.0 ").append(status);
if(message!=null) statusSB.append(" ").append(message);
statusSB.append("\r\n");
- sout.write(statusSB.toString().getBytes(encoding));
+ sout.write(statusSB.toString().getBytes(Constants.CharacterEncoding.Default));
statusSB.setLength(0);
}
@@ -123,7 +115,7 @@
public void addHeader(String name, String value) throws IOException{
headersSB.setLength(0);
headersSB.append(name).append(": ").append(value).append("\r\n");
- sout.write( headersSB.toString().getBytes(encoding) );
+ sout.write( headersSB.toString().getBytes(Constants.CharacterEncoding.Default) );
}
public void addMimeHeaders(MimeHeaders headers) throws IOException {
@@ -133,7 +125,7 @@
MimeHeaderField h = headers.getField(i);
headersSB.append(h).append("\r\n");
}
- sout.write( headersSB.toString().getBytes(encoding) );
+ sout.write( headersSB.toString().getBytes(Constants.CharacterEncoding.Default) );
}
static final byte CRLF[]= { (byte)'\r', (byte)'\n' };
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 2000/01/06 15:35:20
@@ -103,12 +103,11 @@
return (b1<<8) + (b2<<0);
}
- public static String getString( byte b[] , int pos, int len ) {
- return new String( b, pos, len );
+ public static String getString( byte b[] , int pos, int len ) throws UnsupportedEncodingException {
+ return new String( b, pos, len, Constants.CharacterEncoding.Default );
}
-
- 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 +116,9 @@
}
}
if( i+8 <len )
- System.out.print( new String( buff, i, 8 ));
+ System.out.print( new String( buff, i, 8, Constants.CharacterEncoding.Default ));
else
- System.out.print( new String( buff, i, len-i ));
+ System.out.print( new String( buff, i, len-i, Constants.CharacterEncoding.Default ));
System.out.println();
}
System.out.println();
Index: src/share/org/apache/tomcat/util/Constants.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/util/Constants.java,v
retrieving revision 1.1.1.1
diff -u -b -r1.1.1.1 Constants.java
--- Constants.java 1999/10/09 00:20:55 1.1.1.1
+++ Constants.java 2000/01/06 15:35:20
@@ -91,5 +91,9 @@
public static class MIME {
public static final String WAR = "war";
+ }
+
+ public static class CharacterEncoding {
+ public static final String Default = "8859_1";
}
}
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 2000/01/06 15:35:21
@@ -171,8 +171,16 @@
public void parse(byte[] b, int off, int len) {
// 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);
+ try {
+ String dateString = new String(b, off, len, Constants.CharacterEncoding.Default);
parse(dateString);
+ } catch (java.io.UnsupportedEncodingException e) {
+ // It seems rather unlikely that the string encoding would ever fail...
+ // As there is really nothing the caller can do with this specific
+ // exception re-throw the exception as something expected.
+ // XXX - perform byte -> character encoding at a higher level.
+ throw new IllegalArgumentException(e.toString());
+ }
}
public void write(OutputStream out) throws IOException {
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 2000/01/06 15:35:21
@@ -173,8 +173,15 @@
* Returns the message bytes as a String object.
*/
public String toString() {
- return bytes != null ? new String(bytes, offset, length) : null;
+ if (null == bytes) {
+ return null;
}
+ try {
+ return new String(bytes, offset, length, Constants.CharacterEncoding.Default);
+ } catch (java.io.UnsupportedEncodingException e) {
+ return null; // could return something - but why?
+ }
+ }
/**
* Returns the message bytes parsed as an unsigned integer.
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 2000/01/06 15:35:22
@@ -128,7 +128,7 @@
try {
in.read(b);
- count = Integer.parseInt(new String(b).trim());
+ count = Integer.parseInt(new String(b,"UTF8").trim());
} catch (IOException ioe) {
if (this.Debug) {
ioe.printStackTrace();
@@ -183,7 +183,7 @@
try {
in.read(b);
- count = Integer.parseInt(new String(b).trim());
+ count = Integer.parseInt(new String(b,"UTF8").trim());
} catch (IOException ioe) {
if (this.Debug) {
ioe.printStackTrace();
Index: src/tests/share/tests/request/Post.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/tests/share/tests/request/Post.java,v
retrieving revision 1.7
diff -u -b -r1.7 Post.java
--- Post.java 1999/11/12 02:41:41 1.7
+++ Post.java 2000/01/06 15:35:22
@@ -131,10 +131,16 @@
try {
s = SocketHelper.getSocket();
- pw = new PrintWriter(new OutputStreamWriter(
- s.getOutputStream()));
- br = new BufferedReader(new InputStreamReader(
- s.getInputStream()));
+ pw = new PrintWriter(
+ new OutputStreamWriter(
+ s.getOutputStream(),
+ "8859_1"
+ ));
+ br = new BufferedReader(
+ new InputStreamReader(
+ s.getInputStream(),
+ "8859_1"
+ ));
} catch (UnknownHostException uhe) {
uhe.printStackTrace();
} catch (UnsupportedEncodingException uee) {
Index: src/tests/webpages/WEB-INF/classes/Counter.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/tests/webpages/WEB-INF/classes/Counter.java,v
retrieving revision 1.1.1.1
diff -u -b -r1.1.1.1 Counter.java
--- Counter.java 1999/10/09 00:20:58 1.1.1.1
+++ Counter.java 2000/01/06 15:35:22
@@ -67,7 +67,7 @@
res.setContentType(mimeType);
ServletOutputStream out = res.getOutputStream();
- byte[] b = Integer.toString(count).getBytes();
+ byte[] b = Integer.toString(count).getBytes("UTF8");
try {
out.write(b);