439375 preferred rfc7231 format is mime;charset=lowercase-9

This commit is contained in:
Greg Wilkins 2014-07-11 17:56:08 +10:00
parent f9ffefbe13
commit 4d2a580c2c
19 changed files with 120 additions and 125 deletions

View File

@ -705,7 +705,7 @@ public class HttpRequest implements Request
if (value == null)
return "";
String encoding = "UTF-8";
String encoding = "utf-8";
try
{
return URLEncoder.encode(value, encoding);
@ -736,7 +736,7 @@ public class HttpRequest implements Request
private String urlDecode(String value)
{
String charset = "UTF-8";
String charset = "utf-8";
try
{
return URLDecoder.decode(value, charset);

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.fcgi.generator;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@ -46,7 +47,7 @@ public class ClientGenerator extends Generator
{
request &= 0xFF_FF;
Charset utf8 = Charset.forName("UTF-8");
final Charset utf8 = StandardCharsets.UTF_8;
List<byte[]> bytes = new ArrayList<>(fields.size() * 2);
int fieldsLength = 0;
for (HttpField field : fields)

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.fcgi.generator;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@ -54,7 +55,7 @@ public class ServerGenerator extends Generator
{
request &= 0xFF_FF;
Charset utf8 = Charset.forName("UTF-8");
final Charset utf8 = StandardCharsets.UTF_8;
List<byte[]> bytes = new ArrayList<>(fields.size() * 2);
int length = 0;

View File

@ -186,10 +186,12 @@ public class HttpParser
HttpField field=new HttpGenerator.CachedHttpField(HttpHeader.CONTENT_TYPE,type);
CACHE.put(field);
for (String charset : new String[]{"UTF-8","ISO-8859-1"})
for (String charset : new String[]{"utf-8","iso-8859-1"})
{
CACHE.put(new HttpGenerator.CachedHttpField(HttpHeader.CONTENT_TYPE,type+";charset="+charset));
CACHE.put(new HttpGenerator.CachedHttpField(HttpHeader.CONTENT_TYPE,type+"; charset="+charset));
CACHE.put(new HttpGenerator.CachedHttpField(HttpHeader.CONTENT_TYPE,type+";charset="+charset.toUpperCase()));
CACHE.put(new HttpGenerator.CachedHttpField(HttpHeader.CONTENT_TYPE,type+"; charset="+charset.toUpperCase()));
}
}
@ -1234,7 +1236,9 @@ public class HttpParser
BufferUtil.clear(buffer);
Throwable cause = e.getCause();
boolean stack = (cause instanceof RuntimeException) || (cause instanceof Error) || LOG.isDebugEnabled();
boolean stack = LOG.isDebugEnabled() ||
(!(cause instanceof NumberFormatException ) && (cause instanceof RuntimeException || cause instanceof Error));
if (stack)
LOG.warn("bad HTTP parsed: "+e._code+(e.getReason()!=null?" "+e.getReason():"")+" for "+_handler,e);
else

View File

@ -56,20 +56,20 @@ public class MimeTypes
TEXT_JSON("text/json",StandardCharsets.UTF_8),
APPLICATION_JSON("application/json",StandardCharsets.UTF_8),
TEXT_HTML_8859_1("text/html; charset=ISO-8859-1",TEXT_HTML),
TEXT_HTML_UTF_8("text/html; charset=UTF-8",TEXT_HTML),
TEXT_HTML_8859_1("text/html;charset=iso-8859-1",TEXT_HTML),
TEXT_HTML_UTF_8("text/html;charset=utf-8",TEXT_HTML),
TEXT_PLAIN_8859_1("text/plain; charset=ISO-8859-1",TEXT_PLAIN),
TEXT_PLAIN_UTF_8("text/plain; charset=UTF-8",TEXT_PLAIN),
TEXT_PLAIN_8859_1("text/plain;charset=iso-8859-1",TEXT_PLAIN),
TEXT_PLAIN_UTF_8("text/plain;charset=utf-8",TEXT_PLAIN),
TEXT_XML_8859_1("text/xml; charset=ISO-8859-1",TEXT_XML),
TEXT_XML_UTF_8("text/xml; charset=UTF-8",TEXT_XML),
TEXT_XML_8859_1("text/xml;charset=iso-8859-1",TEXT_XML),
TEXT_XML_UTF_8("text/xml;charset=utf-8",TEXT_XML),
TEXT_JSON_8859_1("text/json; charset=ISO-8859-1",TEXT_JSON),
TEXT_JSON_UTF_8("text/json; charset=UTF-8",TEXT_JSON),
TEXT_JSON_8859_1("text/json;charset=iso-8859-1",TEXT_JSON),
TEXT_JSON_UTF_8("text/json;charset=utf-8",TEXT_JSON),
APPLICATION_JSON_8859_1("text/json; charset=ISO-8859-1",APPLICATION_JSON),
APPLICATION_JSON_UTF_8("text/json; charset=UTF-8",APPLICATION_JSON);
APPLICATION_JSON_8859_1("text/json;charset=iso-8859-1",APPLICATION_JSON),
APPLICATION_JSON_UTF_8("text/json;charset=utf-8",APPLICATION_JSON);
/* ------------------------------------------------------------ */
@ -77,6 +77,7 @@ public class MimeTypes
private final Type _base;
private final ByteBuffer _buffer;
private final Charset _charset;
private final String _charsetString;
private final boolean _assumedCharset;
private final HttpField _field;
@ -87,6 +88,7 @@ public class MimeTypes
_buffer=BufferUtil.toBuffer(s);
_base=this;
_charset=null;
_charsetString=null;
_assumedCharset=false;
_field=new HttpGenerator.CachedHttpField(HttpHeader.CONTENT_TYPE,_string);
}
@ -97,8 +99,9 @@ public class MimeTypes
_string=s;
_buffer=BufferUtil.toBuffer(s);
_base=base;
int i=s.indexOf("; charset=");
_charset=Charset.forName(s.substring(i+10));
int i=s.indexOf(";charset=");
_charset=Charset.forName(s.substring(i+9));
_charsetString=_charset==null?null:_charset.toString().toLowerCase();
_assumedCharset=false;
_field=new HttpGenerator.CachedHttpField(HttpHeader.CONTENT_TYPE,_string);
}
@ -110,6 +113,7 @@ public class MimeTypes
_base=this;
_buffer=BufferUtil.toBuffer(s);
_charset=cs;
_charsetString=_charset==null?null:_charset.toString().toLowerCase();
_assumedCharset=true;
_field=new HttpGenerator.CachedHttpField(HttpHeader.CONTENT_TYPE,_string);
}
@ -126,6 +130,12 @@ public class MimeTypes
return _charset;
}
/* ------------------------------------------------------------ */
public String getCharsetString()
{
return _charsetString;
}
/* ------------------------------------------------------------ */
public boolean is(String s)
{
@ -181,8 +191,9 @@ public class MimeTypes
int charset=type.toString().indexOf(";charset=");
if (charset>0)
{
CACHE.put(type.toString().replace(";charset=","; charset="),type);
TYPES.put(type.toString().replace(";charset=","; charset="),type.asBuffer());
String alt=type.toString().replace(";charset=","; charset=");
CACHE.put(alt,type);
TYPES.put(alt,type.asBuffer());
}
}

View File

@ -1,4 +1,4 @@
text/html = ISO-8859-1
text/plain = ISO-8859-1
text/xml = UTF-8
text/json = UTF-8
text/html = iso-8859-1
text/plain = iso-8859-1
text/xml = utf-8
text/json = utf-8

View File

@ -1391,7 +1391,7 @@ public class HttpParserTest
{
ByteBuffer buffer= BufferUtil.toBuffer(
"GET / HTTP/1.1\015\012"
+ "Host: myhost:xxx\015\012"
+ "Host: myhost:testBadPort\015\012"
+ "Connection: close\015\012"
+ "\015\012");

View File

@ -90,9 +90,9 @@ public class MimeTypesTest
assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar other = param ; charset = abc"));
assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar other = param ; charset = \"abc\" ; some=else"));
assertEquals(null,MimeTypes.getCharsetFromContentType("foo/bar"));
assertEquals("UTF-8",MimeTypes.getCharsetFromContentType("foo/bar;charset=uTf8"));
assertEquals("UTF-8",MimeTypes.getCharsetFromContentType("foo/bar;other=\"charset=abc\";charset=uTf8"));
assertEquals("UTF-8",MimeTypes.getCharsetFromContentType("text/html;charset=utf-8"));
assertEquals("utf-8",MimeTypes.getCharsetFromContentType("foo/bar;charset=uTf8"));
assertEquals("utf-8",MimeTypes.getCharsetFromContentType("foo/bar;other=\"charset=abc\";charset=uTf8"));
assertEquals("utf-8",MimeTypes.getCharsetFromContentType("text/html;charset=utf-8"));
}

View File

@ -950,7 +950,7 @@ public class Response implements HttpServletResponse
if (encoding == null)
{
if (_mimeType!=null && _mimeType.isCharsetAssumed())
encoding=_mimeType.getCharset().toString();
encoding=_mimeType.getCharsetString();
else
{
encoding = MimeTypes.inferCharsetFromContentType(_contentType);
@ -1109,7 +1109,7 @@ public class Response implements HttpServletResponse
_characterEncoding = HttpGenerator.__STRICT?encoding:StringUtil.normalizeCharset(encoding);
if (_mimeType!=null)
{
_contentType=_mimeType.getBaseType().asString()+ "; charset=" + _characterEncoding;
_contentType=_mimeType.getBaseType().asString()+ ";charset=" + _characterEncoding;
_mimeType = MimeTypes.CACHE.get(_contentType);
if (_mimeType==null || HttpGenerator.__STRICT)
_fields.put(HttpHeader.CONTENT_TYPE, _contentType);
@ -1118,7 +1118,7 @@ public class Response implements HttpServletResponse
}
else if (_contentType != null)
{
_contentType = MimeTypes.getContentTypeWithoutCharset(_contentType) + "; charset=" + _characterEncoding;
_contentType = MimeTypes.getContentTypeWithoutCharset(_contentType) + ";charset=" + _characterEncoding;
_fields.put(HttpHeader.CONTENT_TYPE, _contentType);
}
}
@ -1149,7 +1149,7 @@ public class Response implements HttpServletResponse
String charset;
if (_mimeType!=null && _mimeType.getCharset()!=null && !_mimeType.isCharsetAssumed())
charset=_mimeType.getCharset().toString();
charset=_mimeType.getCharsetString();
else
charset = MimeTypes.getCharsetFromContentType(contentType);
@ -1157,17 +1157,17 @@ public class Response implements HttpServletResponse
{
if (_characterEncoding != null)
{
_contentType = contentType + "; charset=" + _characterEncoding;
_contentType = contentType + ";charset=" + _characterEncoding;
_mimeType = null;
}
}
else if (isWriting() && !charset.equals(_characterEncoding))
else if (isWriting() && !charset.equalsIgnoreCase(_characterEncoding))
{
// too late to change the character encoding;
_mimeType = null;
_contentType = MimeTypes.getContentTypeWithoutCharset(_contentType);
if (_characterEncoding != null)
_contentType = _contentType + "; charset=" + _characterEncoding;
_contentType = _contentType + ";charset=" + _characterEncoding;
}
else
{

View File

@ -140,7 +140,7 @@ public class ErrorHandler extends AbstractHandler
protected void writeErrorPageHead(HttpServletRequest request, Writer writer, int code, String message)
throws IOException
{
writer.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n");
writer.write("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\n");
writer.write("<title>Error ");
writer.write(Integer.toString(code));

View File

@ -568,7 +568,7 @@ public class ResourceHandler extends HandlerWrapper
if (_directory)
{
String listing = resource.getListHTML(request.getRequestURI(),request.getPathInfo().lastIndexOf("/") > 0);
response.setContentType("text/html; charset=UTF-8");
response.setContentType("text/html;charset=utf-8");
response.getWriter().println(listing);
}
else

View File

@ -360,7 +360,7 @@ public class HttpConnectionTest
"12345\015\012"+
"0;\015\012\015\012");
offset = checkContains(response,offset,"HTTP/1.1 200");
offset = checkContains(response,offset,"encoding=ISO-8859-1");
offset = checkContains(response,offset,"encoding=iso-8859-1");
offset = checkContains(response,offset,"/R1");
offset = checkContains(response,offset,"12345");

View File

@ -106,7 +106,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
+ "</nimbus>\n";
protected static final String RESPONSE2 =
"HTTP/1.1 200 OK\n" +
"Content-Type: text/xml; charset=ISO-8859-1\n" +
"Content-Type: text/xml;charset=iso-8859-1\n" +
"Content-Length: " + RESPONSE2_CONTENT.getBytes().length + "\n" +
"Server: Jetty(" + Server.getVersion() + ")\n" +
"\n" +

View File

@ -129,9 +129,9 @@ public class ResponseTest
response.setContentType("foo/bar");
assertEquals("foo/bar", response.getContentType());
response.getWriter();
assertEquals("foo/bar; charset=ISO-8859-1", response.getContentType());
assertEquals("foo/bar;charset=iso-8859-1", response.getContentType());
response.setContentType("foo2/bar2");
assertEquals("foo2/bar2; charset=ISO-8859-1", response.getContentType());
assertEquals("foo2/bar2;charset=iso-8859-1", response.getContentType());
response.setHeader("name", "foo");
Iterator<String> en = response.getHeaders("name").iterator();
@ -148,16 +148,16 @@ public class ResponseTest
response.setContentType("text/html");
assertEquals("text/html", response.getContentType());
response.getWriter();
assertEquals("text/html; charset=ISO-8859-1", response.getContentType());
assertEquals("text/html;charset=iso-8859-1", response.getContentType());
response.setContentType("foo2/bar2");
assertEquals("foo2/bar2; charset=ISO-8859-1", response.getContentType());
assertEquals("foo2/bar2;charset=iso-8859-1", response.getContentType());
response.recycle();
response.setContentType("text/xml;charset=ISO-8859-7");
response.getWriter();
assertEquals("text/xml;charset=ISO-8859-7", response.getContentType());
response.setContentType("text/html;charset=UTF-8");
assertEquals("text/html; charset=ISO-8859-7", response.getContentType());
assertEquals("text/html;charset=ISO-8859-7", response.getContentType());
response.recycle();
response.setContentType("text/html;charset=US-ASCII");
@ -165,9 +165,9 @@ public class ResponseTest
assertEquals("text/html;charset=US-ASCII", response.getContentType());
response.recycle();
response.setContentType("text/html; charset=utf-8");
response.setContentType("text/html; charset=UTF-8");
response.getWriter();
assertEquals("text/html; charset=UTF-8", response.getContentType());
assertEquals("text/html;charset=utf-8", response.getContentType());
response.recycle();
response.setContentType("text/json");
@ -178,17 +178,17 @@ public class ResponseTest
response.setContentType("text/json");
response.setCharacterEncoding("UTF-8");
response.getWriter();
assertEquals("text/json; charset=UTF-8", response.getContentType());
assertEquals("text/json;charset=utf-8", response.getContentType());
response.recycle();
response.setCharacterEncoding("xyz");
response.setContentType("foo/bar");
assertEquals("foo/bar; charset=xyz", response.getContentType());
assertEquals("foo/bar;charset=xyz", response.getContentType());
response.recycle();
response.setContentType("foo/bar");
response.setCharacterEncoding("xyz");
assertEquals("foo/bar; charset=xyz", response.getContentType());
assertEquals("foo/bar;charset=xyz", response.getContentType());
response.recycle();
response.setCharacterEncoding("xyz");
@ -198,7 +198,7 @@ public class ResponseTest
response.recycle();
response.setContentType("foo/bar;charset=abc");
response.setCharacterEncoding("xyz");
assertEquals("foo/bar; charset=xyz", response.getContentType());
assertEquals("foo/bar;charset=xyz", response.getContentType());
response.recycle();
response.setCharacterEncoding("xyz");
@ -235,14 +235,14 @@ public class ResponseTest
response.setLocale(java.util.Locale.ITALIAN);
assertEquals(null, response.getContentType());
response.setContentType("text/plain");
assertEquals("text/plain; charset=ISO-8859-2", response.getContentType());
assertEquals("text/plain;charset=ISO-8859-2", response.getContentType());
response.recycle();
response.setContentType("text/plain");
response.setCharacterEncoding("utf-8");
response.setLocale(java.util.Locale.ITALIAN);
assertEquals("text/plain; charset=UTF-8", response.getContentType());
assertTrue(response.toString().indexOf("charset=UTF-8") > 0);
assertEquals("text/plain;charset=utf-8", response.getContentType());
assertTrue(response.toString().indexOf("charset=utf-8") > 0);
}
@Test
@ -252,25 +252,25 @@ public class ResponseTest
response.setContentType("foo/bar");
response.setCharacterEncoding("utf-8");
assertEquals("foo/bar; charset=UTF-8", response.getContentType());
assertEquals("foo/bar;charset=utf-8", response.getContentType());
response.getWriter();
assertEquals("foo/bar; charset=UTF-8", response.getContentType());
assertEquals("foo/bar;charset=utf-8", response.getContentType());
response.setContentType("foo2/bar2");
assertEquals("foo2/bar2; charset=UTF-8", response.getContentType());
assertEquals("foo2/bar2;charset=utf-8", response.getContentType());
response.setCharacterEncoding("ISO-8859-1");
assertEquals("foo2/bar2; charset=UTF-8", response.getContentType());
assertEquals("foo2/bar2;charset=utf-8", response.getContentType());
response.recycle();
response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
assertEquals("text/html; charset=UTF-8", response.getContentType());
response.setCharacterEncoding("UTF-8");
assertEquals("text/html;charset=utf-8", response.getContentType());
response.getWriter();
assertEquals("text/html; charset=UTF-8", response.getContentType());
assertEquals("text/html;charset=utf-8", response.getContentType());
response.setContentType("text/xml");
assertEquals("text/xml; charset=UTF-8", response.getContentType());
assertEquals("text/xml;charset=utf-8", response.getContentType());
response.setCharacterEncoding("ISO-8859-1");
assertEquals("text/xml; charset=UTF-8", response.getContentType());
assertEquals("text/xml;charset=utf-8", response.getContentType());
}
@Test
@ -279,25 +279,25 @@ public class ResponseTest
Response response = newResponse();
response.setCharacterEncoding("utf-8");
response.setContentType("foo/bar");
assertEquals("foo/bar; charset=UTF-8", response.getContentType());
assertEquals("foo/bar;charset=utf-8", response.getContentType());
response.getWriter();
assertEquals("foo/bar; charset=UTF-8", response.getContentType());
assertEquals("foo/bar;charset=utf-8", response.getContentType());
response.setContentType("foo2/bar2");
assertEquals("foo2/bar2; charset=UTF-8", response.getContentType());
assertEquals("foo2/bar2;charset=utf-8", response.getContentType());
response.setCharacterEncoding("ISO-8859-1");
assertEquals("foo2/bar2; charset=UTF-8", response.getContentType());
assertEquals("foo2/bar2;charset=utf-8", response.getContentType());
response.recycle();
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
assertEquals("text/html; charset=UTF-8", response.getContentType());
assertEquals("text/html;charset=utf-8", response.getContentType());
response.getWriter();
assertEquals("text/html; charset=UTF-8", response.getContentType());
assertEquals("text/html;charset=utf-8", response.getContentType());
response.setContentType("text/xml");
assertEquals("text/xml; charset=UTF-8", response.getContentType());
assertEquals("text/xml;charset=utf-8", response.getContentType());
response.setCharacterEncoding("iso-8859-1");
assertEquals("text/xml; charset=UTF-8", response.getContentType());
assertEquals("text/xml;charset=utf-8", response.getContentType());
}
@Test
@ -306,26 +306,26 @@ public class ResponseTest
Response response = newResponse();
response.setCharacterEncoding("utf16");
response.setContentType("foo/bar; charset=utf-8");
assertEquals("foo/bar; charset=utf-8", response.getContentType());
response.setContentType("foo/bar; charset=UTF-8");
assertEquals("foo/bar; charset=UTF-8", response.getContentType());
response.getWriter();
assertEquals("foo/bar; charset=utf-8", response.getContentType());
assertEquals("foo/bar; charset=UTF-8", response.getContentType());
response.setContentType("foo2/bar2");
assertEquals("foo2/bar2; charset=UTF-8", response.getContentType());
assertEquals("foo2/bar2;charset=utf-8", response.getContentType());
response.setCharacterEncoding("ISO-8859-1");
assertEquals("foo2/bar2; charset=UTF-8", response.getContentType());
assertEquals("foo2/bar2;charset=utf-8", response.getContentType());
response.recycle();
response.setCharacterEncoding("utf16");
response.setContentType("text/html; charset=utf-8");
assertEquals("text/html; charset=UTF-8", response.getContentType());
assertEquals("text/html;charset=utf-8", response.getContentType());
response.getWriter();
assertEquals("text/html; charset=UTF-8", response.getContentType());
assertEquals("text/html;charset=utf-8", response.getContentType());
response.setContentType("text/xml");
assertEquals("text/xml; charset=UTF-8", response.getContentType());
assertEquals("text/xml;charset=utf-8", response.getContentType());
response.setCharacterEncoding("iso-8859-1");
assertEquals("text/xml; charset=UTF-8", response.getContentType());
assertEquals("text/xml;charset=utf-8", response.getContentType());
}
@Test
@ -336,19 +336,19 @@ public class ResponseTest
response.setContentType("foo/bar; other=xyz");
assertEquals("foo/bar; other=xyz", response.getContentType());
response.getWriter();
assertEquals("foo/bar; other=xyz; charset=ISO-8859-1", response.getContentType());
assertEquals("foo/bar; other=xyz;charset=iso-8859-1", response.getContentType());
response.setContentType("foo2/bar2");
assertEquals("foo2/bar2; charset=ISO-8859-1", response.getContentType());
assertEquals("foo2/bar2;charset=iso-8859-1", response.getContentType());
response.recycle();
response.setCharacterEncoding("utf-8");
response.setCharacterEncoding("uTf-8");
response.setContentType("text/html; other=xyz");
assertEquals("text/html; other=xyz; charset=UTF-8", response.getContentType());
assertEquals("text/html; other=xyz;charset=utf-8", response.getContentType());
response.getWriter();
assertEquals("text/html; other=xyz; charset=UTF-8", response.getContentType());
assertEquals("text/html; other=xyz;charset=utf-8", response.getContentType());
response.setContentType("text/xml");
assertEquals("text/xml; charset=UTF-8", response.getContentType());
assertEquals("text/xml;charset=utf-8", response.getContentType());
}
@Test
@ -366,17 +366,17 @@ public class ResponseTest
response.setCharacterEncoding("utf16");
response.setContentType("text/html; other=xyz charset=utf-8");
assertEquals("text/html; other=xyz charset=utf-8; charset=UTF-16", response.getContentType());
assertEquals("text/html; other=xyz charset=utf-8;charset=utf-16", response.getContentType());
response.getWriter();
assertEquals("text/html; other=xyz charset=utf-8; charset=UTF-16", response.getContentType());
assertEquals("text/html; other=xyz charset=utf-8;charset=utf-16", response.getContentType());
response.recycle();
response.setCharacterEncoding("utf16");
response.setContentType("foo/bar; other=pq charset=utf-8 other=xyz");
assertEquals("foo/bar; other=pq charset=utf-8 other=xyz; charset=UTF-16", response.getContentType());
assertEquals("foo/bar; other=pq charset=utf-8 other=xyz;charset=utf-16", response.getContentType());
response.getWriter();
assertEquals("foo/bar; other=pq charset=utf-8 other=xyz; charset=UTF-16", response.getContentType());
assertEquals("foo/bar; other=pq charset=utf-8 other=xyz;charset=utf-16", response.getContentType());
}
@Test

View File

@ -847,8 +847,8 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
return;
}
data=dir.getBytes("UTF-8");
response.setContentType("text/html; charset=UTF-8");
data=dir.getBytes("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setContentLength(data.length);
response.getOutputStream().write(data);
}

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.util;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.eclipse.jetty.util.log.Log;
@ -46,39 +45,18 @@ public class StringUtil
public static final String __LINE_SEPARATOR=
System.getProperty("line.separator","\n");
public static final String __ISO_8859_1="ISO-8859-1";
public final static String __UTF8="UTF-8";
public final static String __UTF16="UTF-16";
/**
* @deprecated Use {@link StandardCharsets#UTF_8}
*/
@Deprecated
public final static Charset __UTF8_CHARSET=StandardCharsets.UTF_8;
/**
* @deprecated Use {@link StandardCharsets#ISO_8859_1}
*/
@Deprecated
public final static Charset __ISO_8859_1_CHARSET=StandardCharsets.ISO_8859_1;
/**
* @deprecated Use {@link StandardCharsets#UTF_16}
*/
@Deprecated
public final static Charset __UTF16_CHARSET=StandardCharsets.UTF_16;
/**
* @deprecated Use {@link StandardCharsets#US_ASCII}
*/
@Deprecated
public final static Charset __US_ASCII_CHARSET=StandardCharsets.US_ASCII;
public static final String __ISO_8859_1="iso-8859-1";
public final static String __UTF8="utf-8";
public final static String __UTF16="utf-16";
static
{
CHARSETS.put("UTF-8",__UTF8);
CHARSETS.put("UTF8",__UTF8);
CHARSETS.put("UTF-16",__UTF16);
CHARSETS.put("UTF16",__UTF16);
CHARSETS.put("ISO-8859-1",__ISO_8859_1);
CHARSETS.put("ISO_8859_1",__ISO_8859_1);
CHARSETS.put("utf-8",__UTF8);
CHARSETS.put("utf8",__UTF8);
CHARSETS.put("utf-16",__UTF16);
CHARSETS.put("utf16",__UTF16);
CHARSETS.put("iso-8859-1",__ISO_8859_1);
CHARSETS.put("iso_8859_1",__ISO_8859_1);
}
/* ------------------------------------------------------------ */

View File

@ -50,7 +50,7 @@ public class XmlAppendable
public XmlAppendable(Appendable out, int indent) throws IOException
{
this(out,indent,"UTF-8");
this(out,indent,"utf-8");
}
public XmlAppendable(Appendable out, int indent, String encoding) throws IOException

View File

@ -150,7 +150,7 @@ public class XmlConfiguration
*/
public XmlConfiguration(String configuration) throws SAXException, IOException
{
configuration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE Configure PUBLIC \"-//Jetty//Configure//EN\" \"http://eclipse.org/jetty/configure.dtd\">"
configuration = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE Configure PUBLIC \"-//Jetty//Configure//EN\" \"http://eclipse.org/jetty/configure.dtd\">"
+ configuration;
InputSource source = new InputSource(new StringReader(configuration));
synchronized (__parser)

View File

@ -49,7 +49,7 @@ public class XmlAppendableTest
out.closeTag();
String expected = "" +
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<test>\n" +
" <tag/>\n" +
" <tag name=\"attr value\" noval=\"\" quotes=\"&apos;&quot;\"/>\n" +