Author: nextgens
Date: 2006-05-23 15:14:17 +0000 (Tue, 23 May 2006)
New Revision: 8837
Modified:
trunk/freenet/src/freenet/clients/http/HTTPRequest.java
trunk/freenet/src/freenet/clients/http/PageMaker.java
trunk/freenet/src/freenet/clients/http/Toadlet.java
trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
Log:
#0000363 hopefully, all fproxy generated pages will be in UTF8 now
Modified: trunk/freenet/src/freenet/clients/http/HTTPRequest.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/HTTPRequest.java 2006-05-23
14:22:11 UTC (rev 8836)
+++ trunk/freenet/src/freenet/clients/http/HTTPRequest.java 2006-05-23
15:14:17 UTC (rev 8837)
@@ -477,7 +477,7 @@
OutputStream bucketos = filedata.getOutputStream();
// buffer characters that match the boundary so far
byte[] buf = new byte[boundary.length()];
- byte[] bbound = boundary.getBytes();
+ byte[] bbound = boundary.getBytes("UTF-8");
int offset = 0;
while (is.available() > 0 && !boundary.equals(new
String(buf))) {
byte b = (byte)is.read();
Modified: trunk/freenet/src/freenet/clients/http/PageMaker.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PageMaker.java 2006-05-23
14:22:11 UTC (rev 8836)
+++ trunk/freenet/src/freenet/clients/http/PageMaker.java 2006-05-23
15:14:17 UTC (rev 8837)
@@ -48,8 +48,8 @@
+ " html PUBLIC \"-//W3C//DTD XHTML
1.1//EN\">\n"
+ "<html xml:lang=\"en\">\n"
+ "<head>\n"
- + "<meta http-equiv=\"Content-Type\"
content=\"text/html;\" />\n"
- +"<link rel=\"stylesheet\"
href=\"/static/themes/"+this.theme+"/theme.css\" type=\"text/css\" />\n");
+ + "<meta http-equiv=\"Content-Type\"
content=\"text/html; charset=UTF-8\" />\n"
+ + "<link rel=\"stylesheet\"
href=\"/static/themes/"+this.theme+"/theme.css\" type=\"text/css\" />\n");
List themes = getThemes();
for(int i=0; i<themes.size() ; i++){
buf.append("<link rel=\"alternate stylesheet\"
type=\"text/css\" href=\"/static/themes/"+themes.get(i)+"/theme.css\"
media=\"screen\" title=\""+themes.get(i)+"\" />\n");
Modified: trunk/freenet/src/freenet/clients/http/Toadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/Toadlet.java 2006-05-23 14:22:11 UTC
(rev 8836)
+++ trunk/freenet/src/freenet/clients/http/Toadlet.java 2006-05-23 15:14:17 UTC
(rev 8837)
@@ -136,7 +136,7 @@
}
protected void writeReply(ToadletContext ctx, int code, String
mimeType, String desc, String reply) throws ToadletContextClosedException,
IOException {
- byte[] buf = reply.getBytes("ISO-8859-1");
+ byte[] buf = reply.getBytes("UTF-8");
ctx.sendReplyHeaders(code, desc, null, mimeType, buf.length);
ctx.writeData(buf, 0, buf.length);
}
@@ -151,12 +151,12 @@
msg+"</h1><a href=\""+string+"\">Click
here</a></body></html>";
byte[] buf;
try {
- buf = redirDoc.getBytes("ISO-8859-1");
+ buf = redirDoc.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
// No way!
throw new Error(e);
}
- ctx.sendReplyHeaders(301, "Permanent redirect", mvt,
"text/html;charset=ISO-8859-1", buf.length);
+ ctx.sendReplyHeaders(301, "Permanent redirect", mvt,
"text/html; charset=UTF-8", buf.length);
ctx.writeData(buf, 0, buf.length);
}
@@ -178,7 +178,7 @@
buf.append("</div>\n");
buf.append("</div>\n");
ctx.getPageMaker().makeTail(buf);
- writeReply(ctx, code, "text/html", desc, buf.toString());
+ writeReply(ctx, code, "text/html; charset=UTF-8", desc,
buf.toString());
}
/**
Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2006-05-23 14:22:11 UTC (rev 8836)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2006-05-23 15:14:17 UTC (rev 8837)
@@ -69,8 +69,8 @@
if(mvt == null) mvt = new MultiValueTable();
if(disconnect)
mvt.put("Connection", "close");
- byte[] messageBytes = htmlMessage.getBytes("ISO-8859-1");
- sendReplyHeaders(os, code, message, mvt, "text/html",
messageBytes.length);
+ byte[] messageBytes = htmlMessage.getBytes("UTF-8");
+ sendReplyHeaders(os, code, message, mvt, "text/html;
charset=UTF-8", messageBytes.length);
os.write(messageBytes);
}
@@ -101,7 +101,11 @@
if(mvt == null)
mvt = new MultiValueTable();
if(mimeType != null)
- mvt.put("content-type", mimeType);
+ if(mimeType.equalsIgnoreCase("text/html")){
+ mvt.put("content-type", mimeType+";
charset=UTF-8");
+ }else{
+ mvt.put("content-type", mimeType);
+ }
if(contentLength >= 0)
mvt.put("content-length", Long.toString(contentLength));
// FIXME allow caching on a config option.