Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x

This commit is contained in:
Joakim Erdfelt 2021-11-19 16:18:07 -06:00
commit 5a707c890f
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
4 changed files with 13 additions and 30 deletions

View File

@ -14,14 +14,13 @@
package org.eclipse.jetty.client;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpCookie;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.charset.UnsupportedCharsetException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
@ -910,15 +909,7 @@ public class HttpRequest implements Request
if (value == null)
return "";
String encoding = "utf-8";
try
{
return URLEncoder.encode(value, encoding);
}
catch (UnsupportedEncodingException e)
{
throw new UnsupportedCharsetException(encoding);
}
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
private void extractParams(String query)
@ -941,15 +932,7 @@ public class HttpRequest implements Request
private String urlDecode(String value)
{
String charset = "utf-8";
try
{
return URLDecoder.decode(value, charset);
}
catch (UnsupportedEncodingException x)
{
throw new UnsupportedCharsetException(charset);
}
return URLDecoder.decode(value, StandardCharsets.UTF_8);
}
private URI buildURI(boolean withQuery)

View File

@ -13,11 +13,9 @@
package org.eclipse.jetty.client.util;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.util.Fields;
@ -61,13 +59,6 @@ public class FormRequestContent extends StringRequestContent
private static String encode(String value, Charset charset)
{
try
{
return URLEncoder.encode(value, charset.name());
}
catch (UnsupportedEncodingException x)
{
throw new UnsupportedCharsetException(charset.name());
}
return URLEncoder.encode(value, charset);
}
}

View File

@ -14,6 +14,7 @@
package org.eclipse.jetty.util;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@ -578,6 +579,10 @@ public class StringUtil
return new String(b, offset, length, StandardCharsets.UTF_8);
}
/**
* @deprecated use {@link String#String(byte[], int, int, Charset)} instead
*/
@Deprecated(since = "10", forRemoval = true)
public static String toString(byte[] b, int offset, int length, String charset)
{
try

View File

@ -146,7 +146,9 @@ public class UrlEncoded
* @param content the string containing the encoded parameters
* @param map the MultiMap to put parsed query parameters into
* @param charset the charset to use for decoding
* @deprecated use {@link #decodeTo(String, MultiMap, Charset)} instead
*/
@Deprecated(since = "10", forRemoval = true)
public static void decodeTo(String content, MultiMap<String> map, String charset)
{
decodeTo(content, map, charset == null ? null : Charset.forName(charset));
@ -501,7 +503,9 @@ public class UrlEncoded
* @param maxLength the maximum length of the form to decode or -1 for no limit
* @param maxKeys the maximum number of keys to decode or -1 for no limit
* @throws IOException if unable to decode the input stream
* @deprecated use {@link #decodeTo(InputStream, MultiMap, Charset, int, int)} instead
*/
@Deprecated(since = "10", forRemoval = true)
public static void decodeTo(InputStream in, MultiMap<String> map, String charset, int maxLength, int maxKeys)
throws IOException
{