JETTY-1153 System property for UrlEncoded charset
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1181 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
32ae0b68cc
commit
52e5527d47
|
@ -9,6 +9,7 @@ jetty-7.0.2-SNAPSHOT
|
|||
+ 298234 Unit test for jetty-client handling different HTTP error codes
|
||||
+ 298667 DeploymentManager uses ContextProvider and WebAppProvider
|
||||
+ JETTY-910 Allow request listeners to access session
|
||||
+ JETTY-1153 System property for UrlEncoded charset
|
||||
+ JETTY-1155 HttpConnection.close notifies HttpExchange
|
||||
+ JETTY-1156 SSL blocking close with JVM Bug busy key fix
|
||||
+ JETTY-1157 Don't hold array passed in write(byte[])
|
||||
|
|
|
@ -23,13 +23,18 @@ import java.util.Map;
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Handles coding of MIME "x-www-form-urlencoded".
|
||||
* <p>
|
||||
* This class handles the encoding and decoding for either
|
||||
* the query string of a URL or the _content of a POST HTTP request.
|
||||
*
|
||||
* <p><h4>Notes</h4>
|
||||
* <h4>Notes</h4>
|
||||
* The UTF-8 charset is assumed, unless otherwise defined by either
|
||||
* passing a parameter or setting the "org.eclipse.jetty.util.UrlEncoding.charset"
|
||||
* System property.
|
||||
* <p>
|
||||
* The hashtable either contains String single values, vectors
|
||||
* of String or arrays of Strings.
|
||||
*
|
||||
* <p>
|
||||
* This class is only partially synchronised. In particular, simple
|
||||
* get operations are not protected from concurrent updates.
|
||||
*
|
||||
|
@ -38,6 +43,7 @@ import java.util.Map;
|
|||
*/
|
||||
public class UrlEncoded extends MultiMap
|
||||
{
|
||||
public static final String ENCODING = System.getProperty("org.eclipse.jetty.util.UrlEncoding.charset",StringUtil.__UTF8);
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
public UrlEncoded(UrlEncoded url)
|
||||
|
@ -55,7 +61,7 @@ public class UrlEncoded extends MultiMap
|
|||
public UrlEncoded(String s)
|
||||
{
|
||||
super(6);
|
||||
decode(s,StringUtil.__UTF8);
|
||||
decode(s,ENCODING);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
@ -68,7 +74,7 @@ public class UrlEncoded extends MultiMap
|
|||
/* ----------------------------------------------------------------- */
|
||||
public void decode(String query)
|
||||
{
|
||||
decodeTo(query,this,StringUtil.__UTF8);
|
||||
decodeTo(query,this,ENCODING);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
@ -82,7 +88,7 @@ public class UrlEncoded extends MultiMap
|
|||
*/
|
||||
public String encode()
|
||||
{
|
||||
return encode(StringUtil.__UTF8,false);
|
||||
return encode(ENCODING,false);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
|
@ -111,7 +117,7 @@ public class UrlEncoded extends MultiMap
|
|||
public static String encode(MultiMap map, String charset, boolean equalsForNullValue)
|
||||
{
|
||||
if (charset==null)
|
||||
charset=StringUtil.__UTF8;
|
||||
charset=ENCODING;
|
||||
|
||||
StringBuilder result = new StringBuilder(128);
|
||||
|
||||
|
@ -169,7 +175,7 @@ public class UrlEncoded extends MultiMap
|
|||
public static void decodeTo(String content, MultiMap map, String charset)
|
||||
{
|
||||
if (charset==null)
|
||||
charset=StringUtil.__UTF8;
|
||||
charset=ENCODING;
|
||||
|
||||
synchronized(map)
|
||||
{
|
||||
|
@ -394,7 +400,7 @@ public class UrlEncoded extends MultiMap
|
|||
/** Decoded parameters to Map.
|
||||
* @param in InputSteam to read
|
||||
* @param map MultiMap to add parameters to
|
||||
* @param maxLength maximum length of conent to read 0r -1 for no limit
|
||||
* @param maxLength maximum length of content to read 0r -1 for no limit
|
||||
*/
|
||||
public static void decodeUtf8To(InputStream in, MultiMap map, int maxLength)
|
||||
throws IOException
|
||||
|
@ -482,7 +488,7 @@ public class UrlEncoded extends MultiMap
|
|||
maxLength=Integer.MAX_VALUE;
|
||||
while ((c=input.read())>0 && length++<maxLength)
|
||||
buf.append((char)c);
|
||||
decodeTo(buf.toString(),map,StringUtil.__UTF8);
|
||||
decodeTo(buf.toString(),map,ENCODING);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
|
@ -774,13 +780,12 @@ public class UrlEncoded extends MultiMap
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Perform URL encoding.
|
||||
* Assumes 8859 charset
|
||||
* @param string
|
||||
* @return encoded string.
|
||||
*/
|
||||
public static String encodeString(String string)
|
||||
{
|
||||
return encodeString(string,StringUtil.__UTF8);
|
||||
return encodeString(string,ENCODING);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -791,7 +796,7 @@ public class UrlEncoded extends MultiMap
|
|||
public static String encodeString(String string,String charset)
|
||||
{
|
||||
if (charset==null)
|
||||
charset=StringUtil.__UTF8;
|
||||
charset=ENCODING;
|
||||
byte[] bytes=null;
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue