Merge branch 'jetty-9.1' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project into jetty-9.1
This commit is contained in:
commit
4bd1a041f7
142
VERSION.txt
142
VERSION.txt
|
@ -1,3 +1,98 @@
|
|||
jetty-9.1.0.RC1 - 31 October 2013
|
||||
+ 294531 Unpacking webapp twice to the same directory name causes problems
|
||||
with updated jars in WEB-INF/lib
|
||||
+ 397049 Cannot Provide Custom Credential to JDBCLoginService
|
||||
+ 403591 improve the Blocking Q implementation.
|
||||
+ 407716 fixed logs
|
||||
+ 410840 Change SSLSession.getPeerCertificateChain() to
|
||||
SSLSession.getPeerCertificates().
|
||||
+ 415118 WebAppClassLoader.getResource(name) should strip .class from name
|
||||
+ 415609 spdy replace SessionInvoker with IteratingCallback. Introduce Flusher
|
||||
class to separate queuing/flushing logic from StandardSession
|
||||
+ 416300 Order ServletContainerInitializer callbacks
|
||||
+ 416597 Allow classes and jars on the webappcontext extraclasspath to be
|
||||
scanned for annotations by jetty-maven-plugin
|
||||
+ 417356 Add SOCKS support to jetty client.
|
||||
+ 417932 resources.mod should make ${jetty.base}/resources/ directory
|
||||
+ 417933 logging.mod ini template should include commented log.class settings
|
||||
+ 418212 org.eclipse.jetty.spdy.server.http.SSLExternalServerTest hangs.
|
||||
+ 418441 Use of OPTIONS= in Jetty 9.1 should display WARNING message
|
||||
+ 418596 Faults in JARs during class scanning should report the jar that
|
||||
caused the problem
|
||||
+ 418603 cannot specify a custom ServerEndpointConfig.Configurator
|
||||
+ 418625 WebSocket / Jsr RemoteEndpoint.sendObject(java.nio.HeapByteBuffer)
|
||||
doesn't find encoder
|
||||
+ 418632 WebSocket / Jsr annotated @OnMessage with InputStream fails to be
|
||||
called
|
||||
+ 418636 Name anonymous filter and holders with classname-hashcode
|
||||
+ 418732 Add whiteListByPath mode to IPAccessHandler
|
||||
+ 418767 run-forked goal ingores test scope dependencies with
|
||||
useTestScope=true
|
||||
+ 418792 Session getProtocolVersion always returns null
|
||||
+ 418892 SSL session caching so unreliable it effectively does not work.
|
||||
+ 418922 Missing parameterization of etc/jetty-xinetd.xml
|
||||
+ 418923 Missing parameterization of etc/jetty-proxy.xml
|
||||
+ 419146 Parameterize etc/jetty-requestlog.xml values
|
||||
+ 419309 Added symlink checker to test webapp
|
||||
+ 419330 Allow access to setters on jetty-jspc-maven-plugin
|
||||
+ 419333 treat // as an alias in path
|
||||
+ 419344 NPNServerConnection does not close the EndPoint if it reads -1.
|
||||
+ 419350 Do not borrow space from passed arrays
|
||||
+ 419655 AnnotationParser throws NullPointerException when scanning files from
|
||||
jar:file urls
|
||||
+ 419687 HttpClient's query parameters must be case sensitive.
|
||||
+ 419799 Async timeout dispatches to error page
|
||||
+ 419814 Annotation properties maxMessageSize and inputBufferSize don't work
|
||||
+ 419846 JDBCSessionManager doesn't determine dirty state correctly
|
||||
+ 419899 Do not wrap SSL Exception as EoFException
|
||||
+ 419901 Client always adds extra user-agent header.
|
||||
+ 419904 Data corruption on proxy PUT requests.
|
||||
+ 419914 QueuedThreadPool uses nanoTime
|
||||
+ 419937 Request isSecure cleared on recycle
|
||||
+ 419950 Provide constructor for StringContentProvider that takes Charset.
|
||||
+ 419964 InputStreamContentProvider does not close provided InputStream.
|
||||
+ 420012 Improve ProxyServlet.Transparent configuration in case prefix="/".
|
||||
+ 420033 AsyncContext.onTimeout exceptions passed to onError
|
||||
+ 420034 Removed threads/timers from Date caching
|
||||
+ 420039 BufferingResponseListener continues processing after aborting
|
||||
request.
|
||||
+ 420048 DefaultServlet alias checks configured resourceBase
|
||||
+ 420103 Split out jmx-remote module from existing jmx module
|
||||
+ 420142 reimplemented graceful shutdown
|
||||
+ 420362 Response/request listeners called too many times.
|
||||
+ 420364 Bad synchronization in HttpConversation.
|
||||
+ 420374 Call super.close() in a finally block
|
||||
+ 420530 AbstractLoginModule never fails a login
|
||||
+ 420687 XML errors in jetty-plus/src/test/resources/web-fragment-*.xml
|
||||
+ 420776 complete error pages after startAsync
|
||||
|
||||
jetty-9.1.0.RC0 - 30 September 2013
|
||||
+ 412469 make module for jetty-jaspi
|
||||
+ 416453 Add comments to embedded SplitFileServer example
|
||||
+ 416577 enhanced shutdown handler to send shutdown at startup
|
||||
+ 416674 run all jetty-ant tests on random ports
|
||||
+ 416940 avoid download of spring-beans.dtd
|
||||
+ 417152 WebSocket / Do all setup in websocket specific
|
||||
ServletContainerInitializer
|
||||
+ 417239 re-implemented Request.getContentRead()
|
||||
+ 417284 Precompiled regex in HttpField
|
||||
+ 417289 SPDY replace use of direct buffers with indirect buffers or make it
|
||||
configurable
|
||||
+ 417340 Upgrade JDT compiler to one that supports source/target of Java 1.7
|
||||
+ 417382 Upgrade to asm 4.1 and refactor annotation parsing
|
||||
+ 417475 Do not null context Trie during dynamic deploy
|
||||
+ 417490 WebSocket / @PathParam annotated parameters are null when the servlet
|
||||
mapping uses a wildcard
|
||||
+ 417561 Refactor annotation related code: change log messages
|
||||
+ 417574 Setting options with _JAVA_OPTIONS breaks run-forked with
|
||||
<waitForChild>true</waitForChild>
|
||||
+ 417831 Remove jetty-logging.properties from distro/resources
|
||||
+ 417938 Startup / Sort properties presented in --list-config alphabetically
|
||||
+ 418014 Handle NTFS canonical exceptions during alias check
|
||||
+ 418068 WebSocketClient has lazy or injected Executor
|
||||
+ 418212 org.eclipse.jetty.spdy.server.http.SSLExternalServerTest hangs
|
||||
+ 418227 Null cookie value test
|
||||
|
||||
jetty-9.1.0.M0 - 16 September 2013
|
||||
+ 393473 Add support for JSR-356 (javax.websocket) draft
|
||||
+ 395444 Websockets not working with Chrome (deflate problem)
|
||||
|
@ -163,53 +258,10 @@ jetty-9.1.0.M0 - 16 September 2013
|
|||
ServerEndpointConfig.Configurator.getNegotiatedExtensions() is never used
|
||||
+ 417225 added Container.addEventListener method
|
||||
+ 417260 Protected targets matched as true URI path segments
|
||||
|
||||
jetty-9.0.6.v20130930 - 30 September 2013
|
||||
+ 411069 better set compiler defaults to 1.7, including webdefault.xml for jsp
|
||||
+ 411934 War overlay configuration assumes src/main/webapp exists
|
||||
+ 413484 setAttribute in nosql session management better handles _dirty status
|
||||
+ 413684 deprecated unsafe alias checkers
|
||||
+ 413737 hide stacktrace in ReferrerPushStrategyTest
|
||||
+ 414431 Avoid debug NPE race
|
||||
+ 414898 Only upgrade v0 to v1 cookies on dquote , ; backslash space and tab
|
||||
in the value
|
||||
+ 415192 <jsp-file> maps to JspPropertyGroupServlet instead of JspServlet
|
||||
+ 415194 Deployer gives management of context to context collection
|
||||
+ 415302
|
||||
+ 415330 Avoid multiple callbacks at EOF
|
||||
+ 415401 Add initalizeDefaults call to SpringConfigurationProcessor
|
||||
+ 415548 migrate ProxyHTTPToSPDYTest to use HttpClient to avoid intermittent
|
||||
NPE part 2
|
||||
+ 415605 fix status code logging for async requests
|
||||
+ 415999 Fix some of FindBugs warnings
|
||||
+ 416015 Handle null Accept-Language and other headers
|
||||
+ 416096 DefaultServlet leaves open file descriptors with file sizes greater
|
||||
than response buffer
|
||||
+ 416102 Clean up of async sendContent process
|
||||
+ 416103 Added AllowSymLinkAliasChecker.java
|
||||
+ 416251 ProxyHTTPToSPDYConnection now sends a 502 to the client if it
|
||||
receives a rst frame from the upstream spdy server
|
||||
+ 416266 HttpServletResponse.encodeURL() encodes on first request when only
|
||||
SessionTrackingMode.COOKIE is used
|
||||
+ 416314 jetty async client wrong behaviour for HEAD Method + Redirect.
|
||||
+ 416321 handle failure during blocked committing write
|
||||
jetty-9.0.6.v20130930 - 30 September 2013
|
||||
+ 416453 Add comments to embedded SplitFileServer example
|
||||
+ 416477 Improved consumeAll error handling
|
||||
+ 416568 Simplified servlet exception logging
|
||||
+ 416577 enhanced shutdown handler to send shutdown at startup
|
||||
+ 416585 WebInfConfiguration examines webapp classloader first instead of its
|
||||
parent when looking for container jars
|
||||
+ 416597 Allow classes and jars on the webappcontext extraclasspath to be
|
||||
scanned for annotations
|
||||
+ 416663 Content-length set by resourcehandler
|
||||
+ 416674 run all jetty-ant tests on random ports
|
||||
+ 416679 Change warning to debug if no transaction manager present
|
||||
+ 416787 StringIndexOutOfBounds with a pathMap of ""
|
||||
+ 416940 avoid download of spring-beans.dtd
|
||||
+ 416990 JMX names statically unique
|
||||
+ 417110 Demo / html body end tag missing in authfail.html
|
||||
+ 417225 added Container.addEventListener method
|
||||
+ 417260 Protected targets matched as true URI path segments
|
||||
+ 417289 SPDY replace use of direct buffers with indirect buffers or make it
|
||||
configurable
|
||||
+ 417475 Do not null context Trie during dynamic deploy
|
||||
|
@ -219,7 +271,7 @@ jetty-9.1.0.M0 - 16 September 2013
|
|||
+ 418014 Handle NTFS canonical exceptions during alias check
|
||||
+ 418212 org.eclipse.jetty.spdy.server.http.SSLExternalServerTest hangs
|
||||
+ 418227 Null cookie value test
|
||||
|
||||
|
||||
jetty-9.0.5.v20130815 - 15 August 2013
|
||||
+ 414898 Only upgrade v0 to v1 cookies on dquote , ; backslash space and tab
|
||||
in the value
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
|||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
|
|
|
@ -16,12 +16,14 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
|
||||
public class HelloWorld extends AbstractHandler
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.jetty.server.ServerConnector;
|
|||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
||||
public class ExampleServer
|
||||
{
|
||||
|
@ -44,7 +45,6 @@ public class ExampleServer
|
|||
handlers.setHandlers(new Handler[]{context,new DefaultHandler()});
|
||||
server.setHandler(handlers);
|
||||
|
||||
|
||||
server.start();
|
||||
server.join();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.embedded;
|
|||
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ import org.eclipse.jetty.deploy.DeploymentManager;
|
|||
import org.eclipse.jetty.deploy.providers.WebAppProvider;
|
||||
import org.eclipse.jetty.jmx.MBeanContainer;
|
||||
import org.eclipse.jetty.security.HashLoginService;
|
||||
import org.eclipse.jetty.server.ForwardedRequestCustomizer;
|
||||
import org.eclipse.jetty.server.AsyncNCSARequestLog;
|
||||
import org.eclipse.jetty.server.ForwardedRequestCustomizer;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
|
|
|
@ -24,17 +24,11 @@ import java.io.InputStream;
|
|||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarInputStream;
|
||||
|
||||
import org.eclipse.jetty.util.ConcurrentHashSet;
|
||||
|
|
|
@ -18,15 +18,11 @@
|
|||
|
||||
package org.eclipse.jetty.annotations;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.AbstractHandler;
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
|
||||
import org.eclipse.jetty.util.ConcurrentHashSet;
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.annotations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
|
||||
import org.eclipse.jetty.annotations.AnnotationIntrospector.AbstractIntrospectableAnnotationHandler;
|
||||
|
|
|
@ -26,7 +26,6 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.naming.Context;
|
||||
|
@ -37,7 +36,6 @@ import org.eclipse.jetty.annotations.AnnotationParser.ClassInfo;
|
|||
import org.eclipse.jetty.annotations.AnnotationParser.FieldInfo;
|
||||
import org.eclipse.jetty.annotations.AnnotationParser.MethodInfo;
|
||||
import org.eclipse.jetty.util.ConcurrentHashSet;
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ package org.eclipse.jetty.ant;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.security.CodeSource;
|
||||
|
@ -50,7 +48,6 @@ import org.eclipse.jetty.ant.types.FileMatchingConfiguration;
|
|||
import org.eclipse.jetty.ant.utils.TaskLog;
|
||||
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
|
||||
import org.eclipse.jetty.plus.webapp.PlusConfiguration;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.servlet.Holder;
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
package org.eclipse.jetty.ant;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class JettyAntTaskTest
|
||||
{
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -92,13 +93,20 @@ public class HttpContentResponse implements ContentResponse
|
|||
public String getContentAsString()
|
||||
{
|
||||
String encoding = this.encoding;
|
||||
try
|
||||
if (encoding == null)
|
||||
{
|
||||
return new String(getContent(), encoding == null ? "UTF-8" : encoding);
|
||||
return new String(getContent(), StandardCharsets.UTF_8);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
else
|
||||
{
|
||||
throw new UnsupportedCharsetException(encoding);
|
||||
try
|
||||
{
|
||||
return new String(getContent(), encoding);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
throw new UnsupportedCharsetException(encoding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.client.util;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.Authentication;
|
||||
|
@ -28,7 +29,6 @@ import org.eclipse.jetty.client.api.Request;
|
|||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
|
||||
/**
|
||||
* Implementation of the HTTP "Basic" authentication defined in RFC 2617.
|
||||
|
@ -73,8 +73,7 @@ public class BasicAuthentication implements Authentication
|
|||
@Override
|
||||
public Result authenticate(Request request, ContentResponse response, HeaderInfo headerInfo, Attributes context)
|
||||
{
|
||||
String encoding = StringUtil.__ISO_8859_1;
|
||||
String value = "Basic " + B64Code.encode(user + ":" + password, encoding);
|
||||
String value = "Basic " + B64Code.encode(user + ":" + password, StandardCharsets.ISO_8859_1);
|
||||
return new BasicResult(headerInfo.getHeader(), uri, value);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.eclipse.jetty.client.util;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -131,7 +133,7 @@ public abstract class BufferingResponseListener extends Listener.Adapter
|
|||
{
|
||||
String encoding = this.encoding;
|
||||
if (encoding == null)
|
||||
encoding = "UTF-8";
|
||||
return getContentAsString(StandardCharsets.UTF_8);
|
||||
return getContentAsString(encoding);
|
||||
}
|
||||
|
||||
|
@ -151,4 +153,14 @@ public abstract class BufferingResponseListener extends Listener.Adapter
|
|||
throw new UnsupportedCharsetException(encoding);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param encoding the encoding of the content bytes
|
||||
* @return the content as a string, with the specified encoding
|
||||
* @see #getContentAsString()
|
||||
*/
|
||||
public String getContentAsString(Charset encoding)
|
||||
{
|
||||
return new String(getContent(), encoding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.client.util;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
@ -218,14 +217,13 @@ public class DigestAuthentication implements Authentication
|
|||
if (digester == null)
|
||||
return;
|
||||
|
||||
Charset charset = StandardCharsets.ISO_8859_1;
|
||||
String A1 = user + ":" + realm + ":" + password;
|
||||
String hashA1 = toHexString(digester.digest(A1.getBytes(charset)));
|
||||
String hashA1 = toHexString(digester.digest(A1.getBytes(StandardCharsets.ISO_8859_1)));
|
||||
|
||||
String A2 = request.getMethod() + ":" + request.getURI();
|
||||
if ("auth-int".equals(qop))
|
||||
A2 += ":" + toHexString(digester.digest(content));
|
||||
String hashA2 = toHexString(digester.digest(A2.getBytes(charset)));
|
||||
String hashA2 = toHexString(digester.digest(A2.getBytes(StandardCharsets.ISO_8859_1)));
|
||||
|
||||
String nonceCount;
|
||||
String clientNonce;
|
||||
|
@ -242,7 +240,7 @@ public class DigestAuthentication implements Authentication
|
|||
clientNonce = null;
|
||||
A3 = hashA1 + ":" + nonce + ":" + hashA2;
|
||||
}
|
||||
String hashA3 = toHexString(digester.digest(A3.getBytes(charset)));
|
||||
String hashA3 = toHexString(digester.digest(A3.getBytes(StandardCharsets.ISO_8859_1)));
|
||||
|
||||
StringBuilder value = new StringBuilder("Digest");
|
||||
value.append(" username=\"").append(user).append("\"");
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.client.util;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class StringContentProvider extends BytesContentProvider
|
|||
{
|
||||
public StringContentProvider(String content)
|
||||
{
|
||||
this(content, "UTF-8");
|
||||
this(content, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public StringContentProvider(String content, String encoding)
|
||||
|
|
|
@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class GZIPContentDecoderTest
|
|||
data += data;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data.getBytes("UTF-8"));
|
||||
output.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes = baos.toByteArray();
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class GZIPContentDecoderTest
|
|||
int read;
|
||||
while ((read = input.read()) >= 0)
|
||||
baos.write(read);
|
||||
assertEquals(data, new String(baos.toByteArray(), "UTF-8"));
|
||||
assertEquals(data, new String(baos.toByteArray(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -91,13 +91,13 @@ public class GZIPContentDecoderTest
|
|||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data.getBytes("UTF-8"));
|
||||
output.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes = baos.toByteArray();
|
||||
|
||||
GZIPContentDecoder decoder = new GZIPContentDecoder();
|
||||
ByteBuffer decoded = decoder.decode(ByteBuffer.wrap(bytes));
|
||||
assertEquals(data, Charset.forName("UTF-8").decode(decoded).toString());
|
||||
assertEquals(data, StandardCharsets.UTF_8.decode(decoded).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -107,7 +107,7 @@ public class GZIPContentDecoderTest
|
|||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data.getBytes("UTF-8"));
|
||||
output.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes = baos.toByteArray();
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class GZIPContentDecoderTest
|
|||
ByteBuffer decoded = decoder.decode(ByteBuffer.wrap(bytes1));
|
||||
assertEquals(0, decoded.capacity());
|
||||
decoded = decoder.decode(ByteBuffer.wrap(bytes2));
|
||||
assertEquals(data, Charset.forName("UTF-8").decode(decoded).toString());
|
||||
assertEquals(data, StandardCharsets.UTF_8.decode(decoded).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -131,7 +131,7 @@ public class GZIPContentDecoderTest
|
|||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data.getBytes("UTF-8"));
|
||||
output.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes = baos.toByteArray();
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class GZIPContentDecoderTest
|
|||
|
||||
GZIPContentDecoder decoder = new GZIPContentDecoder();
|
||||
ByteBuffer decoded = decoder.decode(ByteBuffer.wrap(bytes1));
|
||||
assertEquals(data, Charset.forName("UTF-8").decode(decoded).toString());
|
||||
assertEquals(data, StandardCharsets.UTF_8.decode(decoded).toString());
|
||||
assertFalse(decoder.isFinished());
|
||||
decoded = decoder.decode(ByteBuffer.wrap(bytes2));
|
||||
assertEquals(0, decoded.remaining());
|
||||
|
@ -157,7 +157,7 @@ public class GZIPContentDecoderTest
|
|||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data.getBytes("UTF-8"));
|
||||
output.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes = baos.toByteArray();
|
||||
|
||||
|
@ -171,7 +171,7 @@ public class GZIPContentDecoderTest
|
|||
ByteBuffer decoded = decoder.decode(ByteBuffer.wrap(bytes1));
|
||||
assertEquals(0, decoded.capacity());
|
||||
decoded = decoder.decode(ByteBuffer.wrap(bytes2));
|
||||
assertEquals(data, Charset.forName("UTF-8").decode(decoded).toString());
|
||||
assertEquals(data, StandardCharsets.UTF_8.decode(decoded).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -180,14 +180,14 @@ public class GZIPContentDecoderTest
|
|||
String data1 = "0";
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data1.getBytes("UTF-8"));
|
||||
output.write(data1.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes1 = baos.toByteArray();
|
||||
|
||||
String data2 = "1";
|
||||
baos = new ByteArrayOutputStream();
|
||||
output = new GZIPOutputStream(baos);
|
||||
output.write(data2.getBytes("UTF-8"));
|
||||
output.write(data2.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes2 = baos.toByteArray();
|
||||
|
||||
|
@ -198,11 +198,11 @@ public class GZIPContentDecoderTest
|
|||
GZIPContentDecoder decoder = new GZIPContentDecoder();
|
||||
ByteBuffer buffer = ByteBuffer.wrap(bytes);
|
||||
ByteBuffer decoded = decoder.decode(buffer);
|
||||
assertEquals(data1, Charset.forName("UTF-8").decode(decoded).toString());
|
||||
assertEquals(data1, StandardCharsets.UTF_8.decode(decoded).toString());
|
||||
assertTrue(decoder.isFinished());
|
||||
assertTrue(buffer.hasRemaining());
|
||||
decoded = decoder.decode(buffer);
|
||||
assertEquals(data2, Charset.forName("UTF-8").decode(decoded).toString());
|
||||
assertEquals(data2, StandardCharsets.UTF_8.decode(decoded).toString());
|
||||
assertTrue(decoder.isFinished());
|
||||
assertFalse(buffer.hasRemaining());
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public class GZIPContentDecoderTest
|
|||
data += data;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data.getBytes("UTF-8"));
|
||||
output.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes = baos.toByteArray();
|
||||
|
||||
|
@ -225,7 +225,7 @@ public class GZIPContentDecoderTest
|
|||
while (buffer.hasRemaining())
|
||||
{
|
||||
ByteBuffer decoded = decoder.decode(buffer);
|
||||
result += Charset.forName("UTF-8").decode(decoded).toString();
|
||||
result += StandardCharsets.UTF_8.decode(decoded).toString();
|
||||
}
|
||||
assertEquals(data, result);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public class GZIPContentDecoderTest
|
|||
data += data;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data.getBytes("UTF-8"));
|
||||
output.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes = baos.toByteArray();
|
||||
|
||||
|
@ -249,7 +249,7 @@ public class GZIPContentDecoderTest
|
|||
{
|
||||
ByteBuffer decoded = decoder.decode(ByteBuffer.wrap(new byte[]{buffer.get()}));
|
||||
if (decoded.hasRemaining())
|
||||
result += Charset.forName("UTF-8").decode(decoded).toString();
|
||||
result += StandardCharsets.UTF_8.decode(decoded).toString();
|
||||
}
|
||||
assertEquals(data, result);
|
||||
assertTrue(decoder.isFinished());
|
||||
|
@ -263,12 +263,12 @@ public class GZIPContentDecoderTest
|
|||
data1 += data1;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream output = new GZIPOutputStream(baos);
|
||||
output.write(data1.getBytes("UTF-8"));
|
||||
output.write(data1.getBytes(StandardCharsets.UTF_8));
|
||||
output.close();
|
||||
byte[] bytes1 = baos.toByteArray();
|
||||
|
||||
String data2 = "HELLO";
|
||||
byte[] bytes2 = data2.getBytes("UTF-8");
|
||||
byte[] bytes2 = data2.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
byte[] bytes = new byte[bytes1.length + bytes2.length];
|
||||
System.arraycopy(bytes1, 0, bytes, 0, bytes1.length);
|
||||
|
@ -281,12 +281,12 @@ public class GZIPContentDecoderTest
|
|||
{
|
||||
ByteBuffer decoded = decoder.decode(buffer);
|
||||
if (decoded.hasRemaining())
|
||||
result += Charset.forName("UTF-8").decode(decoded).toString();
|
||||
result += StandardCharsets.UTF_8.decode(decoded).toString();
|
||||
if (decoder.isFinished())
|
||||
break;
|
||||
}
|
||||
assertEquals(data1, result);
|
||||
assertTrue(buffer.hasRemaining());
|
||||
assertEquals(data2, Charset.forName("UTF-8").decode(buffer).toString());
|
||||
assertEquals(data2, StandardCharsets.UTF_8.decode(buffer).toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,15 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -38,10 +43,6 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* This test class runs tests to make sure that hostname verification (http://www.ietf.org/rfc/rfc2818.txt
|
||||
* section 3.1) is configurable in SslContextFactory and works as expected.
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -21,10 +21,12 @@ package org.eclipse.jetty.client;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -60,13 +62,13 @@ public class HttpClientContinueTest extends AbstractHttpClientServerTest
|
|||
@Test
|
||||
public void test_Expect100Continue_WithOneContent_Respond100Continue() throws Exception
|
||||
{
|
||||
test_Expect100Continue_Respond100Continue("data1".getBytes("UTF-8"));
|
||||
test_Expect100Continue_Respond100Continue("data1".getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Expect100Continue_WithMultipleContents_Respond100Continue() throws Exception
|
||||
{
|
||||
test_Expect100Continue_Respond100Continue("data1".getBytes("UTF-8"), "data2".getBytes("UTF-8"), "data3".getBytes("UTF-8"));
|
||||
test_Expect100Continue_Respond100Continue("data1".getBytes(StandardCharsets.UTF_8), "data2".getBytes(StandardCharsets.UTF_8), "data3".getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private void test_Expect100Continue_Respond100Continue(byte[]... contents) throws Exception
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Random;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -20,8 +20,10 @@ package org.eclipse.jetty.client;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -82,7 +84,7 @@ public class HttpClientProxyTest extends AbstractHttpClientServerTest
|
|||
{
|
||||
final String user = "foo";
|
||||
final String password = "bar";
|
||||
final String credentials = B64Code.encode(user + ":" + password, "ISO-8859-1");
|
||||
final String credentials = B64Code.encode(user + ":" + password, StandardCharsets.ISO_8859_1);
|
||||
final String serverHost = "server";
|
||||
final String realm = "test_realm";
|
||||
final int status = HttpStatus.NO_CONTENT_204;
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import static java.nio.file.StandardOpenOption.CREATE;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -37,6 +41,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -61,10 +66,6 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static java.nio.file.StandardOpenOption.CREATE;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class HttpClientStreamTest extends AbstractHttpClientServerTest
|
||||
{
|
||||
public HttpClientStreamTest(SslContextFactory sslContextFactory)
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import static java.nio.file.StandardOpenOption.CREATE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpCookie;
|
||||
|
@ -25,6 +27,7 @@ import java.net.URI;
|
|||
import java.net.URLEncoder;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.UnresolvedAddressException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -41,6 +44,7 @@ import java.util.concurrent.TimeoutException;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -66,8 +70,6 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static java.nio.file.StandardOpenOption.CREATE;
|
||||
|
||||
public class HttpClientTest extends AbstractHttpClientServerTest
|
||||
{
|
||||
public HttpClientTest(SslContextFactory sslContextFactory)
|
||||
|
@ -174,10 +176,10 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||
response.setCharacterEncoding("UTF-8");
|
||||
ServletOutputStream output = response.getOutputStream();
|
||||
String paramValue1 = request.getParameter(paramName1);
|
||||
output.write(paramValue1.getBytes("UTF-8"));
|
||||
output.write(paramValue1.getBytes(StandardCharsets.UTF_8));
|
||||
String paramValue2 = request.getParameter(paramName2);
|
||||
Assert.assertEquals("", paramValue2);
|
||||
output.write("empty".getBytes("UTF-8"));
|
||||
output.write("empty".getBytes(StandardCharsets.UTF_8));
|
||||
baseRequest.setHandled(true);
|
||||
}
|
||||
});
|
||||
|
@ -189,7 +191,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
String content = new String(response.getContent(), "UTF-8");
|
||||
String content = new String(response.getContent(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(value1 + "empty", content);
|
||||
}
|
||||
|
||||
|
@ -207,9 +209,9 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||
ServletOutputStream output = response.getOutputStream();
|
||||
String[] paramValues1 = request.getParameterValues(paramName1);
|
||||
for (String paramValue : paramValues1)
|
||||
output.write(paramValue.getBytes("UTF-8"));
|
||||
output.write(paramValue.getBytes(StandardCharsets.UTF_8));
|
||||
String paramValue2 = request.getParameter(paramName2);
|
||||
output.write(paramValue2.getBytes("UTF-8"));
|
||||
output.write(paramValue2.getBytes(StandardCharsets.UTF_8));
|
||||
baseRequest.setHandled(true);
|
||||
}
|
||||
});
|
||||
|
@ -225,7 +227,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
String content = new String(response.getContent(), "UTF-8");
|
||||
String content = new String(response.getContent(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(value11 + value12 + value2, content);
|
||||
}
|
||||
|
||||
|
@ -257,7 +259,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
Assert.assertEquals(paramValue, new String(response.getContent(), "UTF-8"));
|
||||
Assert.assertEquals(paramValue, new String(response.getContent(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -289,7 +291,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
Assert.assertEquals(paramValue, new String(response.getContent(), "UTF-8"));
|
||||
Assert.assertEquals(paramValue, new String(response.getContent(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.Executor;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.client;
|
|||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Arrays;
|
|||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.net.HttpCookie;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -102,7 +102,7 @@ public class HttpReceiverTest
|
|||
// Assert.assertNotNull(headers);
|
||||
// Assert.assertEquals(1, headers.size());
|
||||
// Assert.assertEquals(String.valueOf(content.length()), headers.get(HttpHeader.CONTENT_LENGTH));
|
||||
// String received = listener.getContentAsString("UTF-8");
|
||||
// String received = listener.getContentAsString(StandardCharsets.UTF_8);
|
||||
// Assert.assertEquals(content, received);
|
||||
// }
|
||||
//
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -172,7 +172,7 @@ public class HttpSenderTest
|
|||
// HttpConnection connection = new HttpConnection(client, endPoint, destination);
|
||||
// Request request = client.newRequest(URI.create("http://localhost/"));
|
||||
// String content = "abcdef";
|
||||
// request.content(new ByteBufferContentProvider(ByteBuffer.wrap(content.getBytes("UTF-8"))));
|
||||
// request.content(new ByteBufferContentProvider(ByteBuffer.wrap(content.getBytes(StandardCharsets.UTF_8))));
|
||||
// final CountDownLatch headersLatch = new CountDownLatch(1);
|
||||
// final CountDownLatch successLatch = new CountDownLatch(1);
|
||||
// request.listener(new Request.Listener.Adapter()
|
||||
|
@ -207,7 +207,7 @@ public class HttpSenderTest
|
|||
// Request request = client.newRequest(URI.create("http://localhost/"));
|
||||
// String content1 = "0123456789";
|
||||
// String content2 = "abcdef";
|
||||
// request.content(new ByteBufferContentProvider(ByteBuffer.wrap(content1.getBytes("UTF-8")), ByteBuffer.wrap(content2.getBytes("UTF-8"))));
|
||||
// request.content(new ByteBufferContentProvider(ByteBuffer.wrap(content1.getBytes(StandardCharsets.UTF_8)), ByteBuffer.wrap(content2.getBytes(StandardCharsets.UTF_8))));
|
||||
// final CountDownLatch headersLatch = new CountDownLatch(1);
|
||||
// final CountDownLatch successLatch = new CountDownLatch(1);
|
||||
// request.listener(new Request.Listener.Adapter()
|
||||
|
@ -242,7 +242,7 @@ public class HttpSenderTest
|
|||
// Request request = client.newRequest(URI.create("http://localhost/"));
|
||||
// String content1 = "0123456789";
|
||||
// String content2 = "ABCDEF";
|
||||
// request.content(new ByteBufferContentProvider(ByteBuffer.wrap(content1.getBytes("UTF-8")), ByteBuffer.wrap(content2.getBytes("UTF-8")))
|
||||
// request.content(new ByteBufferContentProvider(ByteBuffer.wrap(content1.getBytes(StandardCharsets.UTF_8)), ByteBuffer.wrap(content2.getBytes(StandardCharsets.UTF_8)))
|
||||
// {
|
||||
// @Override
|
||||
// public long getLength()
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.OutputStream;
|
|||
import java.net.HttpCookie;
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -269,7 +270,7 @@ public class Usage
|
|||
HttpClient client = new HttpClient();
|
||||
client.start();
|
||||
|
||||
InputStream input = new ByteArrayInputStream("content".getBytes("UTF-8"));
|
||||
InputStream input = new ByteArrayInputStream("content".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
ContentResponse response = client.newRequest("localhost", 8080)
|
||||
// Provide the content as InputStream
|
||||
|
|
|
@ -24,12 +24,14 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLServerSocket;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
@ -151,7 +153,7 @@ public class SslBytesClientTest extends SslBytesTest
|
|||
|
||||
SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow();
|
||||
// Read request
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(server.getInputStream(), "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(server.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertTrue(line.startsWith("GET"));
|
||||
while (line.length() > 0)
|
||||
|
@ -161,7 +163,7 @@ public class SslBytesClientTest extends SslBytesTest
|
|||
OutputStream output = server.getOutputStream();
|
||||
output.write(("HTTP/1.1 200 OK\r\n" +
|
||||
"Content-Length: 0\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS));
|
||||
|
||||
|
@ -197,7 +199,7 @@ public class SslBytesClientTest extends SslBytesTest
|
|||
|
||||
// Read request
|
||||
InputStream serverInput = server.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(serverInput, "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(serverInput, StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertTrue(line.startsWith("GET"));
|
||||
while (line.length() > 0)
|
||||
|
@ -206,16 +208,16 @@ public class SslBytesClientTest extends SslBytesTest
|
|||
OutputStream serverOutput = server.getOutputStream();
|
||||
byte[] data1 = new byte[1024];
|
||||
Arrays.fill(data1, (byte)'X');
|
||||
String content1 = new String(data1, "UTF-8");
|
||||
String content1 = new String(data1, StandardCharsets.UTF_8);
|
||||
byte[] data2 = new byte[1024];
|
||||
Arrays.fill(data2, (byte)'Y');
|
||||
final String content2 = new String(data2, "UTF-8");
|
||||
final String content2 = new String(data2, StandardCharsets.UTF_8);
|
||||
// Write first part of the response
|
||||
serverOutput.write(("HTTP/1.1 200 OK\r\n" +
|
||||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Length: " + (content1.length() + content2.length()) + "\r\n" +
|
||||
"\r\n" +
|
||||
content1).getBytes("UTF-8"));
|
||||
content1).getBytes(StandardCharsets.UTF_8));
|
||||
serverOutput.flush();
|
||||
Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS));
|
||||
|
||||
|
@ -319,7 +321,7 @@ public class SslBytesClientTest extends SslBytesTest
|
|||
|
||||
// Read request
|
||||
InputStream serverInput = server.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(serverInput, "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(serverInput, StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertTrue(line.startsWith("GET"));
|
||||
while (line.length() > 0)
|
||||
|
@ -328,16 +330,16 @@ public class SslBytesClientTest extends SslBytesTest
|
|||
OutputStream serverOutput = server.getOutputStream();
|
||||
byte[] data1 = new byte[1024];
|
||||
Arrays.fill(data1, (byte)'X');
|
||||
String content1 = new String(data1, "UTF-8");
|
||||
String content1 = new String(data1, StandardCharsets.UTF_8);
|
||||
byte[] data2 = new byte[1024];
|
||||
Arrays.fill(data2, (byte)'Y');
|
||||
final String content2 = new String(data2, "UTF-8");
|
||||
final String content2 = new String(data2, StandardCharsets.UTF_8);
|
||||
// Write first part of the response
|
||||
serverOutput.write(("HTTP/1.1 200 OK\r\n" +
|
||||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Length: " + (content1.length() + content2.length()) + "\r\n" +
|
||||
"\r\n" +
|
||||
content1).getBytes("UTF-8"));
|
||||
content1).getBytes(StandardCharsets.UTF_8));
|
||||
serverOutput.flush();
|
||||
Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS));
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.net.SocketTimeoutException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -586,7 +587,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -628,7 +629,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -644,7 +645,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType());
|
||||
proxy.flushToClient(record);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertNotNull(line);
|
||||
Assert.assertTrue(line.startsWith("HTTP/1.1 200 "));
|
||||
|
@ -721,7 +722,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -738,7 +739,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType());
|
||||
proxy.flushToClient(record);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertNotNull(line);
|
||||
Assert.assertTrue(line.startsWith("HTTP/1.1 200 "));
|
||||
|
@ -801,7 +802,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -876,7 +877,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -946,7 +947,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1005,7 +1006,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1058,7 +1059,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
|
||||
byte[] data = new byte[128 * 1024];
|
||||
Arrays.fill(data, (byte)'X');
|
||||
final String content = new String(data, "UTF-8");
|
||||
final String content = new String(data, StandardCharsets.UTF_8);
|
||||
Future<Object> request = threadPool.submit(new Callable<Object>()
|
||||
{
|
||||
@Override
|
||||
|
@ -1070,7 +1071,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
"Host: localhost\r\n" +
|
||||
"Content-Length: " + content.length() + "\r\n" +
|
||||
"\r\n" +
|
||||
content).getBytes("UTF-8"));
|
||||
content).getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1116,7 +1117,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
|
||||
byte[] data = new byte[128 * 1024];
|
||||
Arrays.fill(data, (byte)'X');
|
||||
final String content = new String(data, "UTF-8");
|
||||
final String content = new String(data, StandardCharsets.UTF_8);
|
||||
Future<Object> request = threadPool.submit(new Callable<Object>()
|
||||
{
|
||||
@Override
|
||||
|
@ -1128,7 +1129,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
"Host: localhost\r\n" +
|
||||
"Content-Length: " + content.length() + "\r\n" +
|
||||
"\r\n" +
|
||||
content).getBytes("UTF-8"));
|
||||
content).getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1190,7 +1191,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1269,7 +1270,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Length: " + content.length() + "\r\n" +
|
||||
"\r\n" +
|
||||
content).getBytes("UTF-8"));
|
||||
content).getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1290,7 +1291,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType());
|
||||
proxy.flushToClient(record);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertNotNull(line);
|
||||
Assert.assertTrue(line.startsWith("HTTP/1.1 200 "));
|
||||
|
@ -1321,7 +1322,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
// Use a content that is larger than the TLS record which is 2^14 (around 16k)
|
||||
byte[] data = new byte[128 * 1024];
|
||||
Arrays.fill(data, (byte)'X');
|
||||
final String content = new String(data, "UTF-8");
|
||||
final String content = new String(data, StandardCharsets.UTF_8);
|
||||
|
||||
Future<Object> request = threadPool.submit(new Callable<Object>()
|
||||
{
|
||||
|
@ -1335,7 +1336,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Length: " + content.length() + "\r\n" +
|
||||
"\r\n" +
|
||||
content).getBytes("UTF-8"));
|
||||
content).getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1367,7 +1368,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType());
|
||||
proxy.flushToClient(record);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertNotNull(line);
|
||||
Assert.assertTrue(line.startsWith("HTTP/1.1 200 "));
|
||||
|
@ -1402,10 +1403,10 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
|
||||
byte[] data1 = new byte[1024];
|
||||
Arrays.fill(data1, (byte)'X');
|
||||
String content1 = new String(data1, "UTF-8");
|
||||
String content1 = new String(data1, StandardCharsets.UTF_8);
|
||||
byte[] data2 = new byte[1024];
|
||||
Arrays.fill(data2, (byte)'Y');
|
||||
final String content2 = new String(data2, "UTF-8");
|
||||
final String content2 = new String(data2, StandardCharsets.UTF_8);
|
||||
|
||||
// Write only part of the body
|
||||
automaticProxyFlow = proxy.startAutomaticFlow();
|
||||
|
@ -1415,7 +1416,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Length: " + (content1.length() + content2.length()) + "\r\n" +
|
||||
"\r\n" +
|
||||
content1).getBytes("UTF-8"));
|
||||
content1).getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS));
|
||||
|
||||
|
@ -1449,7 +1450,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
@Override
|
||||
public Object call() throws Exception
|
||||
{
|
||||
clientOutput.write(content2.getBytes("UTF-8"));
|
||||
clientOutput.write(content2.getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1493,10 +1494,10 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
// Use a content that is larger than the TLS record which is 2^14 (around 16k)
|
||||
byte[] data1 = new byte[80 * 1024];
|
||||
Arrays.fill(data1, (byte)'X');
|
||||
String content1 = new String(data1, "UTF-8");
|
||||
String content1 = new String(data1, StandardCharsets.UTF_8);
|
||||
byte[] data2 = new byte[48 * 1024];
|
||||
Arrays.fill(data2, (byte)'Y');
|
||||
final String content2 = new String(data2, "UTF-8");
|
||||
final String content2 = new String(data2, StandardCharsets.UTF_8);
|
||||
|
||||
// Write only part of the body
|
||||
automaticProxyFlow = proxy.startAutomaticFlow();
|
||||
|
@ -1506,7 +1507,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Length: " + (content1.length() + content2.length()) + "\r\n" +
|
||||
"\r\n" +
|
||||
content1).getBytes("UTF-8"));
|
||||
content1).getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS));
|
||||
|
||||
|
@ -1571,7 +1572,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
@Override
|
||||
public Object call() throws Exception
|
||||
{
|
||||
clientOutput.write(content2.getBytes("UTF-8"));
|
||||
clientOutput.write(content2.getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1593,7 +1594,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType());
|
||||
proxy.flushToClient(record);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertNotNull(line);
|
||||
Assert.assertTrue(line.startsWith("HTTP/1.1 200 "));
|
||||
|
@ -1627,10 +1628,10 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
// Use a content that is larger than the TLS record which is 2^14 (around 16k)
|
||||
byte[] data1 = new byte[80 * 1024];
|
||||
Arrays.fill(data1, (byte)'X');
|
||||
String content1 = new String(data1, "UTF-8");
|
||||
String content1 = new String(data1, StandardCharsets.UTF_8);
|
||||
byte[] data2 = new byte[48 * 1024];
|
||||
Arrays.fill(data2, (byte)'Y');
|
||||
final String content2 = new String(data2, "UTF-8");
|
||||
final String content2 = new String(data2, StandardCharsets.UTF_8);
|
||||
|
||||
// Write only part of the body
|
||||
automaticProxyFlow = proxy.startAutomaticFlow();
|
||||
|
@ -1640,7 +1641,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Length: " + (content1.length() + content2.length()) + "\r\n" +
|
||||
"\r\n" +
|
||||
content1).getBytes("UTF-8"));
|
||||
content1).getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS));
|
||||
|
||||
|
@ -1723,7 +1724,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
@Override
|
||||
public Object call() throws Exception
|
||||
{
|
||||
clientOutput.write(content2.getBytes("UTF-8"));
|
||||
clientOutput.write(content2.getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
return null;
|
||||
}
|
||||
|
@ -1755,7 +1756,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType());
|
||||
proxy.flushToClient(record);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertNotNull(line);
|
||||
Assert.assertTrue(line.startsWith("HTTP/1.1 200 "));
|
||||
|
@ -1786,7 +1787,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
|
||||
byte[] data = new byte[3 * 1024];
|
||||
Arrays.fill(data, (byte)'Y');
|
||||
String content = new String(data, "UTF-8");
|
||||
String content = new String(data, StandardCharsets.UTF_8);
|
||||
automaticProxyFlow = proxy.startAutomaticFlow();
|
||||
clientOutput.write(("" +
|
||||
"POST / HTTP/1.1\r\n" +
|
||||
|
@ -1795,10 +1796,10 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
"Content-Length: " + content.length() + "\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"\r\n" +
|
||||
content).getBytes("UTF-8"));
|
||||
content).getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = reader.readLine();
|
||||
Assert.assertNotNull(line);
|
||||
Assert.assertTrue(line.startsWith("HTTP/1.1 200 "));
|
||||
|
@ -1844,7 +1845,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
});
|
||||
|
||||
// Instead of passing the Client Hello, we simulate plain text was passed in
|
||||
proxy.flushToServer(0, "GET / HTTP/1.1\r\n".getBytes("UTF-8"));
|
||||
proxy.flushToServer(0, "GET / HTTP/1.1\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// We expect that the server closes the connection immediately
|
||||
TLSRecord record = proxy.readFromServer();
|
||||
|
@ -1878,7 +1879,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
clientOutput.write(("" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n").getBytes("UTF-8"));
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
clientOutput.flush();
|
||||
latch.countDown();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.deploy.test;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
|
|
@ -64,27 +64,6 @@ public class DelegatingThreadPool extends ContainerLifeCycle implements ThreadPo
|
|||
_executor.execute(job);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public boolean dispatch(Runnable job)
|
||||
{
|
||||
final Executor executor=_executor;
|
||||
if (executor instanceof ThreadPool)
|
||||
return ((ThreadPool)executor).dispatch(job);
|
||||
|
||||
try
|
||||
{
|
||||
_executor.execute(job);
|
||||
return true;
|
||||
}
|
||||
catch(RejectedExecutionException e)
|
||||
{
|
||||
LOG.warn(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public int getIdleThreads()
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
|
||||
import com.sun.net.httpserver.Authenticator;
|
||||
import com.sun.net.httpserver.Authenticator.Result;
|
||||
import com.sun.net.httpserver.BasicAuthenticator;
|
||||
import com.sun.net.httpserver.HttpContext;
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
|
|
|
@ -18,25 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.http.spi;
|
||||
|
||||
import com.sun.net.httpserver.HttpContext;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
|
@ -45,6 +26,21 @@ import java.util.Map;
|
|||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
import com.sun.net.httpserver.HttpContext;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
|
||||
/**
|
||||
* Jetty implementation of {@link com.sun.net.httpserver.HttpServer}.
|
||||
*/
|
||||
|
|
|
@ -23,10 +23,9 @@ import java.net.InetSocketAddress;
|
|||
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.util.thread.ExecutorThreadPool;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.http;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTokens.EndOfContent;
|
||||
import org.eclipse.jetty.util.ArrayTernaryTrie;
|
||||
|
@ -1025,12 +1026,12 @@ public class HttpParser
|
|||
// Have to get the fields exactly from the buffer to match case
|
||||
String fn=field.getName();
|
||||
String fv=field.getValue();
|
||||
n=BufferUtil.toString(buffer,buffer.position()-1,fn.length(),StringUtil.__US_ASCII_CHARSET);
|
||||
n=BufferUtil.toString(buffer,buffer.position()-1,fn.length(),StandardCharsets.US_ASCII);
|
||||
if (fv==null)
|
||||
v=null;
|
||||
else
|
||||
{
|
||||
v=BufferUtil.toString(buffer,buffer.position()+fn.length()+1,fv.length(),StringUtil.__ISO_8859_1_CHARSET);
|
||||
v=BufferUtil.toString(buffer,buffer.position()+fn.length()+1,fv.length(),StandardCharsets.ISO_8859_1);
|
||||
field=new HttpField(field.getHeader(),n,v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.http.HttpGenerator.RequestInfo;
|
||||
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
|
||||
|
@ -346,7 +347,7 @@ public class HttpTester
|
|||
|
||||
String content_type=get(HttpHeader.CONTENT_TYPE);
|
||||
String encoding=MimeTypes.getCharsetFromContentType(content_type);
|
||||
Charset charset=encoding==null?StringUtil.__UTF8_CHARSET:Charset.forName(encoding);
|
||||
Charset charset=encoding==null?StandardCharsets.UTF_8:Charset.forName(encoding);
|
||||
|
||||
return new String(bytes,charset);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.http;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
|
@ -100,15 +101,7 @@ public class HttpURI
|
|||
public HttpURI(String raw)
|
||||
{
|
||||
_rawString=raw;
|
||||
byte[] b;
|
||||
try
|
||||
{
|
||||
b = raw.getBytes(StringUtil.__UTF8);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
byte[] b = raw.getBytes(StandardCharsets.UTF_8);
|
||||
parse(b,0,b.length);
|
||||
_charset = URIUtil.__CHARSET;
|
||||
}
|
||||
|
@ -617,8 +610,13 @@ public class HttpURI
|
|||
return StringUtil.toUTF8String(_raw, _path, _param-_path);
|
||||
return utf8b.toString();
|
||||
}
|
||||
|
||||
|
||||
public String getDecodedPath(String encoding)
|
||||
{
|
||||
return getDecodedPath(Charset.forName(encoding));
|
||||
}
|
||||
|
||||
public String getDecodedPath(Charset encoding)
|
||||
{
|
||||
if (_path==_param)
|
||||
return null;
|
||||
|
@ -678,9 +676,9 @@ public class HttpURI
|
|||
|
||||
|
||||
if (bytes==null)
|
||||
return StringUtil.toString(_raw,_path,_param-_path,encoding);
|
||||
return new String(_raw,_path,_param-_path,encoding);
|
||||
|
||||
return StringUtil.toString(bytes,0,n,encoding);
|
||||
return new String(bytes,0,n,encoding);
|
||||
}
|
||||
|
||||
public String getPathAndParam()
|
||||
|
@ -734,10 +732,10 @@ public class HttpURI
|
|||
{
|
||||
if (_query==_fragment)
|
||||
return;
|
||||
if (_charset==StringUtil.__UTF8_CHARSET)
|
||||
if (_charset.equals(StandardCharsets.UTF_8))
|
||||
UrlEncoded.decodeUtf8To(_raw,_query+1,_fragment-_query-1,parameters);
|
||||
else
|
||||
UrlEncoded.decodeTo(StringUtil.toString(_raw,_query+1,_fragment-_query-1,_charset.toString()),parameters,_charset.toString(),-1);
|
||||
UrlEncoded.decodeTo(new String(_raw,_query+1,_fragment-_query-1,_charset),parameters,_charset,-1);
|
||||
}
|
||||
|
||||
public void decodeQueryTo(MultiMap<String> parameters, String encoding) throws UnsupportedEncodingException
|
||||
|
@ -751,6 +749,17 @@ public class HttpURI
|
|||
UrlEncoded.decodeTo(StringUtil.toString(_raw,_query+1,_fragment-_query-1,encoding),parameters,encoding,-1);
|
||||
}
|
||||
|
||||
public void decodeQueryTo(MultiMap<String> parameters, Charset encoding) throws UnsupportedEncodingException
|
||||
{
|
||||
if (_query==_fragment)
|
||||
return;
|
||||
|
||||
if (encoding==null || StandardCharsets.UTF_8.equals(encoding))
|
||||
UrlEncoded.decodeUtf8To(_raw,_query+1,_fragment-_query-1,parameters);
|
||||
else
|
||||
UrlEncoded.decodeTo(new String(_raw,_query+1,_fragment-_query-1,encoding),parameters,encoding,-1);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
_scheme=_authority=_host=_port=_path=_param=_query=_fragment=_end=0;
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Map;
|
|||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.jetty.util.ArrayTernaryTrie;
|
||||
import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.Trie;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HttpGeneratorServerTest
|
||||
|
|
|
@ -24,12 +24,12 @@ import static org.junit.Assert.assertThat;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.http.HttpParser.State;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -112,7 +112,7 @@ public class HttpParserTest
|
|||
@Test
|
||||
public void testLineParse3() throws Exception
|
||||
{
|
||||
ByteBuffer buffer= BufferUtil.toBuffer("POST /fo\u0690 HTTP/1.0\015\012" + "\015\012",StringUtil.__UTF8_CHARSET);
|
||||
ByteBuffer buffer= BufferUtil.toBuffer("POST /fo\u0690 HTTP/1.0\015\012" + "\015\012",StandardCharsets.UTF_8);
|
||||
|
||||
HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
|
||||
HttpParser parser= new HttpParser(handler);
|
||||
|
@ -126,7 +126,7 @@ public class HttpParserTest
|
|||
@Test
|
||||
public void testLineParse4() throws Exception
|
||||
{
|
||||
ByteBuffer buffer= BufferUtil.toBuffer("POST /foo?param=\u0690 HTTP/1.0\015\012" + "\015\012",StringUtil.__UTF8_CHARSET);
|
||||
ByteBuffer buffer= BufferUtil.toBuffer("POST /foo?param=\u0690 HTTP/1.0\015\012" + "\015\012",StandardCharsets.UTF_8);
|
||||
|
||||
HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
|
||||
HttpParser parser= new HttpParser(handler);
|
||||
|
@ -346,10 +346,10 @@ public class HttpParserTest
|
|||
ByteBuffer buffer=BufferUtil.allocate(4096);
|
||||
BufferUtil.flipToFill(buffer);
|
||||
BufferUtil.put(BufferUtil.toBuffer("GET "),buffer);
|
||||
buffer.put("/foo/\u0690/".getBytes(StringUtil.__UTF8_CHARSET));
|
||||
buffer.put("/foo/\u0690/".getBytes(StandardCharsets.UTF_8));
|
||||
BufferUtil.put(BufferUtil.toBuffer(" HTTP/1.0\r\n"),buffer);
|
||||
BufferUtil.put(BufferUtil.toBuffer("Header1: "),buffer);
|
||||
buffer.put("\u00e6 \u00e6".getBytes(StringUtil.__ISO_8859_1_CHARSET));
|
||||
buffer.put("\u00e6 \u00e6".getBytes(StandardCharsets.ISO_8859_1));
|
||||
BufferUtil.put(BufferUtil.toBuffer(" \r\n\r\n"),buffer);
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
|
@ -1348,7 +1348,7 @@ public class HttpParserTest
|
|||
{
|
||||
if (_content==null)
|
||||
_content="";
|
||||
String c = BufferUtil.toString(ref,StringUtil.__UTF8_CHARSET);
|
||||
String c = BufferUtil.toString(ref,StandardCharsets.UTF_8);
|
||||
//System.err.println("content '"+c+"'");
|
||||
_content= _content + c;
|
||||
ref.position(ref.limit());
|
||||
|
|
|
@ -23,9 +23,9 @@ import java.net.InetSocketAddress;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
@ -153,7 +153,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
|||
/* ------------------------------------------------------------ */
|
||||
public void setInput(String s)
|
||||
{
|
||||
setInput(BufferUtil.toBuffer(s,StringUtil.__UTF8_CHARSET));
|
||||
setInput(BufferUtil.toBuffer(s,StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -177,7 +177,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
|||
*/
|
||||
public String getOutputString()
|
||||
{
|
||||
return getOutputString(StringUtil.__UTF8_CHARSET);
|
||||
return getOutputString(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -207,7 +207,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
|||
*/
|
||||
public String takeOutputString()
|
||||
{
|
||||
return takeOutputString(StringUtil.__UTF8_CHARSET);
|
||||
return takeOutputString(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -163,6 +163,33 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
final ManagedSelector selector = chooseSelector();
|
||||
selector.submit(selector.new Accept(channel));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Registers a channel to select accept operations.
|
||||
* When a {@link SocketChannel} is accepted from this {@link ServerSocketChannel}
|
||||
* then the {@link #accepted(SocketChannel)} method is called, which must be
|
||||
* overridden by a derivation of this class to handle the accepted channel
|
||||
*
|
||||
* @param channel the server channel to register
|
||||
*/
|
||||
public void acceptor(final ServerSocketChannel server)
|
||||
{
|
||||
final ManagedSelector selector = chooseSelector();
|
||||
selector.submit(selector.new Acceptor(server));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback method when a channel is accepted from the {@link ServerSocketChannel}
|
||||
* passed in {@link #acceptor(ServerSocketChannel)}.
|
||||
* The default impl throws an {@link UnsupportedOperationException}, so it must
|
||||
* be overridden if selected acceptor is to be used.
|
||||
* @param channel
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void accepted(SocketChannel channel) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
|
@ -544,6 +571,10 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
{
|
||||
processConnect(key, (Connect)attachment);
|
||||
}
|
||||
else if (key.isAcceptable())
|
||||
{
|
||||
processAccept(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
|
@ -587,6 +618,23 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
connect.failed(x);
|
||||
}
|
||||
}
|
||||
|
||||
private void processAccept(SelectionKey key)
|
||||
{
|
||||
ServerSocketChannel server = (ServerSocketChannel)key.channel();
|
||||
try
|
||||
{
|
||||
SocketChannel channel;
|
||||
while ((channel=server.accept())!=null)
|
||||
{
|
||||
accepted(channel);
|
||||
}
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.warn("Accept failed",x);
|
||||
}
|
||||
}
|
||||
|
||||
private void closeNoExceptions(Closeable closeable)
|
||||
{
|
||||
|
@ -723,6 +771,31 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
}
|
||||
}
|
||||
|
||||
private class Acceptor implements Runnable
|
||||
{
|
||||
private final ServerSocketChannel _channel;
|
||||
|
||||
public Acceptor(ServerSocketChannel channel)
|
||||
{
|
||||
this._channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
SelectionKey key = _channel.register(_selector, SelectionKey.OP_ACCEPT, null);
|
||||
LOG.debug("{} acceptor={}",this,key);
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
closeNoExceptions(_channel);
|
||||
LOG.warn(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Accept implements Runnable
|
||||
{
|
||||
private final SocketChannel _channel;
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.io;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -33,14 +34,14 @@ import java.io.Writer;
|
|||
public class WriterOutputStream extends OutputStream
|
||||
{
|
||||
protected final Writer _writer;
|
||||
protected final String _encoding;
|
||||
protected final Charset _encoding;
|
||||
private final byte[] _buf=new byte[1];
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public WriterOutputStream(Writer writer, String encoding)
|
||||
{
|
||||
_writer=writer;
|
||||
_encoding=encoding;
|
||||
_encoding=encoding==null?null:Charset.forName(encoding);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.io.ssl;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
|
|
|
@ -29,13 +29,13 @@ import java.io.IOException;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.AsynchronousServerSocketChannel;
|
||||
import java.nio.channels.AsynchronousSocketChannel;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -49,15 +49,13 @@ import org.junit.Test;
|
|||
public class IOTest
|
||||
{
|
||||
@Test
|
||||
public void testIO() throws InterruptedException
|
||||
public void testIO() throws Exception
|
||||
{
|
||||
// Only a little test
|
||||
ByteArrayInputStream in = new ByteArrayInputStream("The quick brown fox jumped over the lazy dog".getBytes());
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
IO.copyThread(in, out);
|
||||
Thread.sleep(1500);
|
||||
// System.err.println(out);
|
||||
IO.copy(in, out);
|
||||
|
||||
assertEquals("copyThread", out.toString(), "The quick brown fox jumped over the lazy dog");
|
||||
}
|
||||
|
@ -444,7 +442,7 @@ public class IOTest
|
|||
ByteBuffer read = ByteBuffer.allocate(1024);
|
||||
Future<Integer> reading = server.read(read);
|
||||
|
||||
byte[] data = "Testing 1 2 3".getBytes("UTF-8");
|
||||
byte[] data = "Testing 1 2 3".getBytes(StandardCharsets.UTF_8);
|
||||
ByteBuffer write = BufferUtil.toBuffer(data);
|
||||
Future<Integer> writing = client.write(write);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.eclipse.jetty.io;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.util.thread.TimerScheduler;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -18,11 +18,17 @@
|
|||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
|
@ -39,10 +45,6 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
||||
{
|
||||
|
@ -170,7 +172,7 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
|||
if (debug) System.err.println("\nSay Hello");
|
||||
|
||||
// write a message
|
||||
appOut.put("HelloWorld".getBytes("UTF-8"));
|
||||
appOut.put("HelloWorld".getBytes(StandardCharsets.UTF_8));
|
||||
appOut.flip();
|
||||
SSLEngineResult result =engine.wrap(appOut,sslOut);
|
||||
if (debug) System.err.println(result);
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -29,13 +35,13 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
@ -46,12 +52,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SelectChannelEndPointTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SelectChannelEndPointTest.class);
|
||||
|
@ -228,7 +228,7 @@ public class SelectChannelEndPointTest
|
|||
_manager.accept(server);
|
||||
|
||||
// Write client to server
|
||||
client.getOutputStream().write("HelloWorld".getBytes("UTF-8"));
|
||||
client.getOutputStream().write("HelloWorld".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Verify echo server to client
|
||||
for (char c : "HelloWorld".toCharArray())
|
||||
|
@ -253,7 +253,7 @@ public class SelectChannelEndPointTest
|
|||
}
|
||||
|
||||
// write then shutdown
|
||||
client.getOutputStream().write("Goodbye Cruel TLS".getBytes("UTF-8"));
|
||||
client.getOutputStream().write("Goodbye Cruel TLS".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Verify echo server to client
|
||||
for (char c : "Goodbye Cruel TLS".toCharArray())
|
||||
|
@ -287,7 +287,7 @@ public class SelectChannelEndPointTest
|
|||
_manager.accept(server);
|
||||
|
||||
// Write client to server
|
||||
client.getOutputStream().write("HelloWorld".getBytes("UTF-8"));
|
||||
client.getOutputStream().write("HelloWorld".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Verify echo server to client
|
||||
for (char c : "HelloWorld".toCharArray())
|
||||
|
@ -310,7 +310,7 @@ public class SelectChannelEndPointTest
|
|||
}
|
||||
|
||||
// write then shutdown
|
||||
client.getOutputStream().write("Goodbye Cruel TLS".getBytes("UTF-8"));
|
||||
client.getOutputStream().write("Goodbye Cruel TLS".getBytes(StandardCharsets.UTF_8));
|
||||
client.shutdownOutput();
|
||||
|
||||
// Verify echo server to client
|
||||
|
@ -343,7 +343,7 @@ public class SelectChannelEndPointTest
|
|||
|
||||
// Write 8 and cause block waiting for 10
|
||||
_blockAt = 10;
|
||||
clientOutputStream.write("12345678".getBytes("UTF-8"));
|
||||
clientOutputStream.write("12345678".getBytes(StandardCharsets.UTF_8));
|
||||
clientOutputStream.flush();
|
||||
|
||||
Assert.assertTrue(_lastEndPointLatch.await(1, TimeUnit.SECONDS));
|
||||
|
@ -363,7 +363,7 @@ public class SelectChannelEndPointTest
|
|||
}
|
||||
|
||||
// write remaining characters
|
||||
clientOutputStream.write("90ABCDEF".getBytes("UTF-8"));
|
||||
clientOutputStream.write("90ABCDEF".getBytes(StandardCharsets.UTF_8));
|
||||
clientOutputStream.flush();
|
||||
|
||||
// Verify echo server to client
|
||||
|
@ -388,7 +388,7 @@ public class SelectChannelEndPointTest
|
|||
_manager.accept(server);
|
||||
|
||||
// Write client to server
|
||||
client.getOutputStream().write("HelloWorld".getBytes("UTF-8"));
|
||||
client.getOutputStream().write("HelloWorld".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Verify echo server to client
|
||||
for (char c : "HelloWorld".toCharArray())
|
||||
|
@ -436,7 +436,7 @@ public class SelectChannelEndPointTest
|
|||
_manager.accept(server);
|
||||
|
||||
// Write client to server
|
||||
clientOutputStream.write("HelloWorld".getBytes("UTF-8"));
|
||||
clientOutputStream.write("HelloWorld".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Verify echo server to client
|
||||
for (char c : "HelloWorld".toCharArray())
|
||||
|
@ -452,7 +452,7 @@ public class SelectChannelEndPointTest
|
|||
|
||||
// Write 8 and cause block waiting for 10
|
||||
_blockAt = 10;
|
||||
clientOutputStream.write("12345678".getBytes("UTF-8"));
|
||||
clientOutputStream.write("12345678".getBytes(StandardCharsets.UTF_8));
|
||||
clientOutputStream.flush();
|
||||
|
||||
// read until idle shutdown received
|
||||
|
@ -493,8 +493,8 @@ public class SelectChannelEndPointTest
|
|||
_manager.accept(server);
|
||||
final int writes = 200000;
|
||||
|
||||
final byte[] bytes = "HelloWorld-".getBytes(StringUtil.__UTF8_CHARSET);
|
||||
byte[] count = "0\n".getBytes(StringUtil.__UTF8_CHARSET);
|
||||
final byte[] bytes = "HelloWorld-".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] count = "0\n".getBytes(StandardCharsets.UTF_8);
|
||||
BufferedOutputStream out = new BufferedOutputStream(client.getOutputStream());
|
||||
final CountDownLatch latch = new CountDownLatch(writes);
|
||||
final InputStream in = new BufferedInputStream(client.getInputStream());
|
||||
|
@ -561,7 +561,7 @@ public class SelectChannelEndPointTest
|
|||
for (int i = 1; i < writes; i++)
|
||||
{
|
||||
out.write(bytes);
|
||||
out.write(Integer.toString(i).getBytes(StringUtil.__ISO_8859_1_CHARSET));
|
||||
out.write(Integer.toString(i).getBytes(StandardCharsets.ISO_8859_1));
|
||||
out.write('\n');
|
||||
if (i % 1000 == 0)
|
||||
{
|
||||
|
@ -599,7 +599,7 @@ public class SelectChannelEndPointTest
|
|||
// Write client to server
|
||||
_writeCount = 10000;
|
||||
String data = "Now is the time for all good men to come to the aid of the party";
|
||||
client.getOutputStream().write(data.getBytes("UTF-8"));
|
||||
client.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||
BufferedInputStream in = new BufferedInputStream(client.getInputStream());
|
||||
|
||||
int byteNum = 0;
|
||||
|
|
|
@ -27,9 +27,11 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
|
@ -37,7 +39,6 @@ import org.eclipse.jetty.io.ssl.SslConnection;
|
|||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
@ -61,12 +62,11 @@ public class SslConnectionTest
|
|||
final AtomicInteger _dispatches = new AtomicInteger();
|
||||
protected QueuedThreadPool _threadPool = new QueuedThreadPool()
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean dispatch(Runnable job)
|
||||
public void execute(Runnable job)
|
||||
{
|
||||
_dispatches.incrementAndGet();
|
||||
return super.dispatch(job);
|
||||
super.execute(job);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -234,14 +234,14 @@ public class SslConnectionTest
|
|||
server.configureBlocking(false);
|
||||
_manager.accept(server);
|
||||
|
||||
client.getOutputStream().write("Hello".getBytes("UTF-8"));
|
||||
client.getOutputStream().write("Hello".getBytes(StandardCharsets.UTF_8));
|
||||
byte[] buffer = new byte[1024];
|
||||
int len=client.getInputStream().read(buffer);
|
||||
Assert.assertEquals(5, len);
|
||||
Assert.assertEquals("Hello",new String(buffer,0,len,StringUtil.__UTF8_CHARSET));
|
||||
Assert.assertEquals("Hello",new String(buffer,0,len,StandardCharsets.UTF_8));
|
||||
|
||||
_dispatches.set(0);
|
||||
client.getOutputStream().write("World".getBytes("UTF-8"));
|
||||
client.getOutputStream().write("World".getBytes(StandardCharsets.UTF_8));
|
||||
len=5;
|
||||
while(len>0)
|
||||
len-=client.getInputStream().read(buffer);
|
||||
|
@ -266,7 +266,7 @@ public class SslConnectionTest
|
|||
|
||||
byte[] buffer = new byte[1024];
|
||||
int len=client.getInputStream().read(buffer);
|
||||
Assert.assertEquals("Hello Client",new String(buffer,0,len,StringUtil.__UTF8_CHARSET));
|
||||
Assert.assertEquals("Hello Client",new String(buffer,0,len,StandardCharsets.UTF_8));
|
||||
Assert.assertEquals(null,_writeCallback.get(100,TimeUnit.MILLISECONDS));
|
||||
client.close();
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ public class SslConnectionTest
|
|||
{
|
||||
try
|
||||
{
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream(),StringUtil.__UTF8_CHARSET));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream(),StandardCharsets.UTF_8));
|
||||
while(count.getCount()>0)
|
||||
{
|
||||
String line=in.readLine();
|
||||
|
@ -311,7 +311,7 @@ public class SslConnectionTest
|
|||
|
||||
for (int i=0;i<LINES;i++)
|
||||
{
|
||||
client.getOutputStream().write(("HelloWorld "+i+"\n").getBytes("UTF-8"));
|
||||
client.getOutputStream().write(("HelloWorld "+i+"\n").getBytes(StandardCharsets.UTF_8));
|
||||
// System.err.println("wrote");
|
||||
if (i%1000==0)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,15 @@
|
|||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.WritePendingException;
|
||||
|
@ -46,15 +55,6 @@ import org.mockito.invocation.InvocationOnMock;
|
|||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class WriteFlusherTest
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.security.jaspi.modules;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -41,7 +42,6 @@ import org.eclipse.jetty.security.authentication.LoginCallbackImpl;
|
|||
import org.eclipse.jetty.security.jaspi.JaspiMessageInfo;
|
||||
import org.eclipse.jetty.security.jaspi.callback.CredentialValidationCallback;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.security.Credential;
|
||||
import org.eclipse.jetty.util.security.Password;
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class BaseAuthModule implements ServerAuthModule, ServerAuthContext
|
|||
throws IOException, UnsupportedCallbackException
|
||||
{
|
||||
credentials = credentials.substring(credentials.indexOf(' ')+1);
|
||||
credentials = B64Code.decode(credentials,StringUtil.__ISO_8859_1);
|
||||
credentials = B64Code.decode(credentials, StandardCharsets.ISO_8859_1);
|
||||
int i = credentials.indexOf(':');
|
||||
String userName = credentials.substring(0,i);
|
||||
String password = credentials.substring(i+1);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.security.jaspi.modules;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -35,7 +36,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -306,18 +306,18 @@ public class DigestAuthModule extends BaseAuthModule
|
|||
else
|
||||
{
|
||||
// calc A1 digest
|
||||
md.update(username.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(username.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(realm.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(realm.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(password.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(password.getBytes(StandardCharsets.ISO_8859_1));
|
||||
ha1 = md.digest();
|
||||
}
|
||||
// calc A2 digest
|
||||
md.reset();
|
||||
md.update(method.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(method.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(uri.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(uri.getBytes(StandardCharsets.ISO_8859_1));
|
||||
byte[] ha2 = md.digest();
|
||||
|
||||
// calc digest
|
||||
|
@ -327,17 +327,17 @@ public class DigestAuthModule extends BaseAuthModule
|
|||
// request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2)
|
||||
// ) > <">
|
||||
|
||||
md.update(TypeUtil.toString(ha1, 16).getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(TypeUtil.toString(ha1, 16).getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(nonce.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(nonce.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(nc.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(nc.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(cnonce.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(cnonce.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(qop.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(qop.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(TypeUtil.toString(ha2, 16).getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(TypeUtil.toString(ha2, 16).getBytes(StandardCharsets.ISO_8859_1));
|
||||
byte[] digest = md.digest();
|
||||
|
||||
// check digest
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.jmx;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.jndi.java;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -47,11 +46,9 @@ import javax.servlet.ServletContextListener;
|
|||
import org.eclipse.jetty.jndi.NamingContext;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -20,13 +20,11 @@
|
|||
package org.eclipse.jetty.maven.plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* OverlayConfig
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.plus.annotation;
|
|||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.plus.webapp;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.eclipse.jetty.plus.annotation.InjectionCollection;
|
||||
import org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection;
|
||||
import org.eclipse.jetty.plus.annotation.RunAsCollection;
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
|
|
|
@ -32,7 +32,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.session.AbstractSessionIdManager;
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
@ -78,7 +79,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -98,7 +99,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
|
|||
"GET /echo HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -121,7 +122,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -145,7 +146,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
|
|||
"Content-Length: 5\r\n" +
|
||||
"\r\n" +
|
||||
"HELLO";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.io.OutputStream;
|
|||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
|
@ -71,7 +72,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -93,7 +94,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -104,7 +105,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo" + " HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -130,7 +131,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 403 from the CONNECT request
|
||||
|
@ -151,7 +152,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 from the CONNECT request
|
||||
|
@ -162,7 +163,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo" + " HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -188,7 +189,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 403 from the CONNECT request
|
||||
|
@ -209,7 +210,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 from the CONNECT request
|
||||
|
@ -220,7 +221,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo" + " HTTP/1.1\r\n" +
|
||||
"Host: 127.0.0.1:" + port + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -245,7 +246,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
return false;
|
||||
}
|
||||
String b64 = proxyAuthorization.substring("Basic ".length());
|
||||
String credentials = B64Code.decode(b64, "UTF-8");
|
||||
String credentials = B64Code.decode(b64, StandardCharsets.UTF_8);
|
||||
return "test:test".equals(credentials);
|
||||
}
|
||||
};
|
||||
|
@ -265,7 +266,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 407 from the CONNECT request
|
||||
|
@ -289,7 +290,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 from the CONNECT request
|
||||
|
@ -300,7 +301,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo" + " HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -342,7 +343,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 500 OK from the CONNECT request
|
||||
|
@ -368,7 +369,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -379,7 +380,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo" + " HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -404,7 +405,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -431,7 +432,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -444,7 +445,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo" + " HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -467,7 +468,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -478,7 +479,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -506,7 +507,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -517,7 +518,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /close HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
int read = input.read();
|
||||
|
@ -538,7 +539,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -551,7 +552,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"Content-Length: 5\r\n" +
|
||||
"\r\n" +
|
||||
"HELLO";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -562,7 +563,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo" + " HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -585,7 +586,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -603,7 +604,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"Content-Length: " + body.length() + "\r\n" +
|
||||
"\r\n" +
|
||||
body;
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -649,7 +650,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -663,7 +664,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"Content-Length: " + body.length() + "\r\n" +
|
||||
"\r\n" +
|
||||
body;
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = readResponse(input);
|
||||
|
@ -688,7 +689,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
socket.shutdownOutput();
|
||||
|
||||
|
@ -716,7 +717,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
OutputStream output = socket.getOutputStream();
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
// Expect 200 OK from the CONNECT request
|
||||
|
@ -727,7 +728,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
|
|||
"GET /echo" + " HTTP/1.1\r\n" +
|
||||
"Host: " + hostPort + "\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
socket.shutdownOutput();
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.proxy;
|
||||
|
||||
import static java.nio.file.StandardOpenOption.CREATE;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -37,6 +39,7 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
@ -76,8 +79,6 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static java.nio.file.StandardOpenOption.CREATE;
|
||||
|
||||
@RunWith(AdvancedRunner.class)
|
||||
public class ProxyServletTest
|
||||
{
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.proxy;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
|
@ -26,6 +28,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -61,8 +64,6 @@ import org.junit.Ignore;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ProxyTunnellingTest
|
||||
{
|
||||
@Rule
|
||||
|
|
|
@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.util.ArrayTernaryTrie;
|
||||
import org.eclipse.jetty.util.StringMap;
|
||||
import org.eclipse.jetty.util.Trie;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.rewrite.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
package org.eclipse.jetty.rewrite.handler;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class RewritePatternRuleTest extends AbstractRuleTestCase
|
||||
{
|
||||
private String[][] _tests =
|
||||
|
|
|
@ -21,10 +21,10 @@ package org.eclipse.jetty.rewrite.handler;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.UrlEncoded;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -87,7 +87,7 @@ public class RewriteRegexRuleTest extends AbstractRuleTestCase
|
|||
if (test[5]!=null)
|
||||
{
|
||||
MultiMap<String> params=new MultiMap<String>();
|
||||
UrlEncoded.decodeTo(test[5],params,StringUtil.__UTF8_CHARSET,-1);
|
||||
UrlEncoded.decodeTo(test[5],params, StandardCharsets.UTF_8,-1);
|
||||
|
||||
for (String n:params.keySet())
|
||||
assertEquals(params.getString(n),_request.getParameter(n));
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.security.authentication;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
@ -32,7 +33,6 @@ import org.eclipse.jetty.server.Authentication;
|
|||
import org.eclipse.jetty.server.Authentication.User;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
|
||||
/**
|
||||
|
@ -82,7 +82,7 @@ public class BasicAuthenticator extends LoginAuthenticator
|
|||
if ("basic".equalsIgnoreCase(method))
|
||||
{
|
||||
credentials = credentials.substring(space+1);
|
||||
credentials = B64Code.decode(credentials,StringUtil.__ISO_8859_1);
|
||||
credentials = B64Code.decode(credentials, StandardCharsets.ISO_8859_1);
|
||||
int i = credentials.indexOf(':');
|
||||
if (i>0)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.security.authentication;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.BitSet;
|
||||
|
@ -42,7 +43,6 @@ import org.eclipse.jetty.server.Request;
|
|||
import org.eclipse.jetty.server.UserIdentity;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -367,18 +367,18 @@ public class DigestAuthenticator extends LoginAuthenticator
|
|||
else
|
||||
{
|
||||
// calc A1 digest
|
||||
md.update(username.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(username.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(realm.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(realm.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(password.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(password.getBytes(StandardCharsets.ISO_8859_1));
|
||||
ha1 = md.digest();
|
||||
}
|
||||
// calc A2 digest
|
||||
md.reset();
|
||||
md.update(method.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(method.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(uri.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(uri.getBytes(StandardCharsets.ISO_8859_1));
|
||||
byte[] ha2 = md.digest();
|
||||
|
||||
// calc digest
|
||||
|
@ -388,17 +388,17 @@ public class DigestAuthenticator extends LoginAuthenticator
|
|||
// request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2)
|
||||
// ) > <">
|
||||
|
||||
md.update(TypeUtil.toString(ha1, 16).getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(TypeUtil.toString(ha1, 16).getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(nonce.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(nonce.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(nc.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(nc.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(cnonce.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(cnonce.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(qop.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(qop.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(TypeUtil.toString(ha2, 16).getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(TypeUtil.toString(ha2, 16).getBytes(StandardCharsets.ISO_8859_1));
|
||||
byte[] digest = md.digest();
|
||||
|
||||
// check digest
|
||||
|
|
|
@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.eclipse.jetty.security.Authenticator;
|
||||
import org.eclipse.jetty.security.Authenticator.AuthConfiguration;
|
||||
import org.eclipse.jetty.security.IdentityService;
|
||||
import org.eclipse.jetty.security.LoginService;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
|
|
|
@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -64,10 +65,8 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.util.security.Credential;
|
||||
import org.eclipse.jetty.util.security.Password;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -569,17 +568,17 @@ public class ConstraintTest
|
|||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] ha1;
|
||||
// calc A1 digest
|
||||
md.update(username.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(username.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update("TestRealm".getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update("TestRealm".getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(password.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(password.getBytes(StandardCharsets.ISO_8859_1));
|
||||
ha1 = md.digest();
|
||||
// calc A2 digest
|
||||
md.reset();
|
||||
md.update("GET".getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update("GET".getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(uri.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(uri.getBytes(StandardCharsets.ISO_8859_1));
|
||||
byte[] ha2 = md.digest();
|
||||
|
||||
// calc digest
|
||||
|
@ -589,17 +588,17 @@ public class ConstraintTest
|
|||
// request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2)
|
||||
// ) > <">
|
||||
|
||||
md.update(TypeUtil.toString(ha1, 16).getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(TypeUtil.toString(ha1, 16).getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(nonce.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(nonce.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(nc.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(nc.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(CNONCE.getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(CNONCE.getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update("auth".getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update("auth".getBytes(StandardCharsets.ISO_8859_1));
|
||||
md.update((byte) ':');
|
||||
md.update(TypeUtil.toString(ha2, 16).getBytes(StringUtil.__ISO_8859_1));
|
||||
md.update(TypeUtil.toString(ha2, 16).getBytes(StandardCharsets.ISO_8859_1));
|
||||
byte[] digest = md.digest();
|
||||
|
||||
// check digest
|
||||
|
|
|
@ -189,7 +189,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
for (ConnectionFactory factory:factories)
|
||||
addConnectionFactory(factory);
|
||||
|
||||
if (acceptors<=0)
|
||||
if (acceptors<0)
|
||||
acceptors=Math.max(1,(Runtime.getRuntime().availableProcessors()) / 2);
|
||||
if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
|
||||
LOG.warn("Acceptors should be <= 2*availableProcessors: " + this);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
|
||||
/**
|
||||
* <p>An implementation of HttpInput using {@link ByteBuffer} as items.</p>
|
||||
*/
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -50,7 +51,6 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
import org.eclipse.jetty.server.handler.ErrorHandler;
|
||||
import org.eclipse.jetty.util.BlockingCallback;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -491,7 +491,7 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
|
|||
{
|
||||
LOG.warn("Failed UTF-8 decode for request path, trying ISO-8859-1");
|
||||
LOG.ignore(e);
|
||||
path = _uri.getDecodedPath(StringUtil.__ISO_8859_1);
|
||||
path = _uri.getDecodedPath(StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
String info = URIUtil.canonicalPath(path);
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.eclipse.jetty.server;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.servlet.AsyncEvent;
|
||||
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletContext;
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.jetty.io.ByteBufferPool;
|
|||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.util.BlockingCallback;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.IteratingNestedCallback;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.WritePendingException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.ServletRequest;
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
|
@ -30,7 +31,6 @@ import org.eclipse.jetty.io.ByteArrayEndPoint;
|
|||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
||||
|
@ -47,22 +47,22 @@ public class LocalConnector extends AbstractConnector
|
|||
|
||||
public LocalConnector(Server server)
|
||||
{
|
||||
this(server, null, null, null, 0, new HttpConnectionFactory());
|
||||
this(server, null, null, null, -1, new HttpConnectionFactory());
|
||||
}
|
||||
|
||||
public LocalConnector(Server server, SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server, null, null, null, 0,AbstractConnectionFactory.getFactories(sslContextFactory,new HttpConnectionFactory()));
|
||||
this(server, null, null, null, -1,AbstractConnectionFactory.getFactories(sslContextFactory,new HttpConnectionFactory()));
|
||||
}
|
||||
|
||||
public LocalConnector(Server server, ConnectionFactory connectionFactory)
|
||||
{
|
||||
this(server, null, null, null, 0, connectionFactory);
|
||||
this(server, null, null, null, -1, connectionFactory);
|
||||
}
|
||||
|
||||
public LocalConnector(Server server, ConnectionFactory connectionFactory, SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server, null, null, null, 0, AbstractConnectionFactory.getFactories(sslContextFactory,connectionFactory));
|
||||
this(server, null, null, null, -1, AbstractConnectionFactory.getFactories(sslContextFactory,connectionFactory));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,8 +100,8 @@ public class LocalConnector extends AbstractConnector
|
|||
*/
|
||||
public String getResponses(String requests,long idleFor,TimeUnit units) throws Exception
|
||||
{
|
||||
ByteBuffer result = getResponses(BufferUtil.toBuffer(requests,StringUtil.__UTF8_CHARSET),idleFor,units);
|
||||
return result==null?null:BufferUtil.toString(result,StringUtil.__UTF8_CHARSET);
|
||||
ByteBuffer result = getResponses(BufferUtil.toBuffer(requests,StandardCharsets.UTF_8),idleFor,units);
|
||||
return result==null?null:BufferUtil.toString(result,StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/** Sends requests and get's responses based on thread activity.
|
||||
|
@ -150,7 +150,7 @@ public class LocalConnector extends AbstractConnector
|
|||
*/
|
||||
public LocalEndPoint executeRequest(String rawRequest)
|
||||
{
|
||||
return executeRequest(BufferUtil.toBuffer(rawRequest,StringUtil.__UTF8_CHARSET));
|
||||
return executeRequest(BufferUtil.toBuffer(rawRequest, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private LocalEndPoint executeRequest(ByteBuffer rawRequest)
|
||||
|
@ -190,7 +190,7 @@ public class LocalConnector extends AbstractConnector
|
|||
// TODO this is a busy wait
|
||||
while(getIn()==null || BufferUtil.hasContent(getIn()))
|
||||
Thread.yield();
|
||||
setInput(BufferUtil.toBuffer(s, StringUtil.__UTF8_CHARSET));
|
||||
setInput(BufferUtil.toBuffer(s, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
|
||||
import org.eclipse.jetty.util.ArrayQueue;
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
|
@ -39,6 +40,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.DispatcherType;
|
||||
|
@ -1873,7 +1875,7 @@ public class Request implements HttpServletRequest
|
|||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Set the character encoding used for the query string. This call will effect the return of getQueryString and getParamaters. It must be called before any
|
||||
* geParameter methods.
|
||||
* getParameter methods.
|
||||
*
|
||||
* The request attribute "org.eclipse.jetty.server.server.Request.queryEncoding" may be set as an alternate method of calling setQueryEncoding.
|
||||
*
|
||||
|
@ -2100,6 +2102,7 @@ public class Request implements HttpServletRequest
|
|||
setAttribute(__MULTIPART_INPUT_STREAM, _multiPartInputStream);
|
||||
setAttribute(__MULTIPART_CONTEXT, _context);
|
||||
Collection<Part> parts = _multiPartInputStream.getParts(); //causes parsing
|
||||
ByteArrayOutputStream os = null;
|
||||
for (Part p:parts)
|
||||
{
|
||||
MultiPartInputStreamParser.MultiPart mp = (MultiPartInputStreamParser.MultiPart)p;
|
||||
|
@ -2110,21 +2113,17 @@ public class Request implements HttpServletRequest
|
|||
if (mp.getContentType() != null)
|
||||
charset = MimeTypes.getCharsetFromContentType(mp.getContentType());
|
||||
|
||||
ByteArrayOutputStream os = null;
|
||||
InputStream is = mp.getInputStream(); //get the bytes regardless of being in memory or in temp file
|
||||
try
|
||||
//get the bytes regardless of being in memory or in temp file
|
||||
try (InputStream is = mp.getInputStream())
|
||||
{
|
||||
os = new ByteArrayOutputStream();
|
||||
if (os == null)
|
||||
os = new ByteArrayOutputStream();
|
||||
IO.copy(is, os);
|
||||
String content=new String(os.toByteArray(),charset==null?StringUtil.__UTF8:charset);
|
||||
String content=new String(os.toByteArray(),charset==null?StandardCharsets.UTF_8:Charset.forName(charset));
|
||||
getParameter(""); //cause params to be evaluated
|
||||
getParameters().add(mp.getName(), content);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IO.close(os);
|
||||
IO.close(is);
|
||||
}
|
||||
os.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2169,7 +2168,7 @@ public class Request implements HttpServletRequest
|
|||
{
|
||||
// extract parameters from dispatch query
|
||||
MultiMap<String> parameters = new MultiMap<>();
|
||||
UrlEncoded.decodeTo(query,parameters, StringUtil.__UTF8_CHARSET,-1); //have to assume UTF-8 because we can't know otherwise
|
||||
UrlEncoded.decodeTo(query,parameters, StandardCharsets.UTF_8,-1); //have to assume UTF-8 because we can't know otherwise
|
||||
|
||||
boolean merge_old_query = false;
|
||||
|
||||
|
@ -2194,7 +2193,7 @@ public class Request implements HttpServletRequest
|
|||
|
||||
|
||||
MultiMap<String> overridden_new_query = new MultiMap<>();
|
||||
UrlEncoded.decodeTo(query,overridden_new_query,StringUtil.__UTF8_CHARSET,-1); //have to assume utf8 as we cannot know otherwise
|
||||
UrlEncoded.decodeTo(query,overridden_new_query,StandardCharsets.UTF_8,-1); //have to assume utf8 as we cannot know otherwise
|
||||
|
||||
for(String name: overridden_old_query.keySet())
|
||||
{
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import org.eclipse.jetty.http.DateGenerator;
|
||||
import org.eclipse.jetty.http.HttpContent;
|
||||
import org.eclipse.jetty.http.HttpContent.ResourceAsHttpContent;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.nio.channels.IllegalSelectorException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
|
@ -34,18 +33,17 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.eclipse.jetty.http.DateGenerator;
|
||||
import org.eclipse.jetty.http.HttpContent;
|
||||
import org.eclipse.jetty.http.HttpCookie;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
|
||||
import org.eclipse.jetty.http.DateGenerator;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
|
@ -73,6 +71,15 @@ public class Response implements HttpServletResponse
|
|||
private static final String __COOKIE_DELIM="\",;\\ \t";
|
||||
private final static String __01Jan1970_COOKIE = DateGenerator.formatCookieDate(0).trim();
|
||||
|
||||
// Cookie building buffer. Reduce garbage for cookie using applications
|
||||
private static final ThreadLocal<StringBuilder> __cookieBuilder = new ThreadLocal<StringBuilder>()
|
||||
{
|
||||
@Override
|
||||
protected StringBuilder initialValue()
|
||||
{
|
||||
return new StringBuilder(128);
|
||||
}
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static Response getResponse(HttpServletResponse response)
|
||||
|
@ -265,7 +272,8 @@ public class Response implements HttpServletResponse
|
|||
throw new IllegalArgumentException("Bad cookie name");
|
||||
|
||||
// Format value and params
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
StringBuilder buf = __cookieBuilder.get();
|
||||
buf.setLength(0);
|
||||
|
||||
// Name is checked for legality by servlet spec, but can also be passed directly so check again for quoting
|
||||
boolean quote_name=isQuoteNeededForCookie(name);
|
||||
|
|
|
@ -61,6 +61,7 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ShutdownThread;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Jetty HTTP Servlet Server.
|
||||
|
@ -300,6 +301,24 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
HttpGenerator.setJettyVersion(HttpConfiguration.SERVER_VERSION);
|
||||
MultiException mex=new MultiException();
|
||||
|
||||
// check size of thread pool
|
||||
SizedThreadPool pool = getBean(SizedThreadPool.class);
|
||||
int max=pool==null?-1:pool.getMaxThreads();
|
||||
int needed=1;
|
||||
if (mex.size()==0)
|
||||
{
|
||||
for (Connector connector : _connectors)
|
||||
{
|
||||
if (connector instanceof AbstractConnector)
|
||||
needed+=((AbstractConnector)connector).getAcceptors();
|
||||
if (connector instanceof ServerConnector)
|
||||
needed+=((ServerConnector)connector).getSelectorManager().getSelectorCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (max>0 && needed>=max)
|
||||
throw new IllegalStateException("Insufficient max threads in ThreadPool: max="+max+" < needed="+needed);
|
||||
|
||||
try
|
||||
{
|
||||
super.doStart();
|
||||
|
@ -309,21 +328,19 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
mex.add(e);
|
||||
}
|
||||
|
||||
if (mex.size()==0)
|
||||
// start connectors last
|
||||
for (Connector connector : _connectors)
|
||||
{
|
||||
for (Connector _connector : _connectors)
|
||||
try
|
||||
{
|
||||
connector.start();
|
||||
}
|
||||
catch(Throwable e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_connector.start();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
mex.add(e);
|
||||
}
|
||||
mex.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isDumpAfterStart())
|
||||
dumpStdErr();
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
public ServerConnector(
|
||||
@Name("server") Server server)
|
||||
{
|
||||
this(server,null,null,null,0,0,new HttpConnectionFactory());
|
||||
this(server,null,null,null,-1,-1,new HttpConnectionFactory());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -104,9 +104,10 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.</p>
|
||||
* @param server The {@link Server} this connector will accept connection for.
|
||||
* @param acceptors
|
||||
* the number of acceptor threads to use, or 0 for a default value. Acceptors accept new TCP/IP connections.
|
||||
* the number of acceptor threads to use, or -1 for a default value. Acceptors accept new TCP/IP connections. If 0, then
|
||||
* the selector threads are used to accept connections.
|
||||
* @param selectors
|
||||
* the number of selector threads, or 0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||
* the number of selector threads, or -1 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||
*/
|
||||
public ServerConnector(
|
||||
@Name("server") Server server,
|
||||
|
@ -126,7 +127,7 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
@Name("server") Server server,
|
||||
@Name("factories") ConnectionFactory... factories)
|
||||
{
|
||||
this(server,null,null,null,0,0,factories);
|
||||
this(server,null,null,null,-1,-1,factories);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -140,7 +141,7 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
@Name("server") Server server,
|
||||
@Name("sslContextFactory") SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server,null,null,null,0,0,AbstractConnectionFactory.getFactories(sslContextFactory,new HttpConnectionFactory()));
|
||||
this(server,null,null,null,-1,-1,AbstractConnectionFactory.getFactories(sslContextFactory,new HttpConnectionFactory()));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -150,9 +151,10 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
* @param sslContextFactory If non null, then a {@link SslConnectionFactory} is instantiated and prepended to the
|
||||
* list of HTTP Connection Factory.
|
||||
* @param acceptors
|
||||
* the number of acceptor threads to use, or 0 for a default value. Acceptors accept new TCP/IP connections.
|
||||
* the number of acceptor threads to use, or -1 for a default value. Acceptors accept new TCP/IP connections. If 0, then
|
||||
* the selector threads are used to accept connections.
|
||||
* @param selectors
|
||||
* the number of selector threads, or 0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||
* the number of selector threads, or -1 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||
*/
|
||||
public ServerConnector(
|
||||
@Name("server") Server server,
|
||||
|
@ -175,7 +177,7 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
@Name("sslContextFactory") SslContextFactory sslContextFactory,
|
||||
@Name("factories") ConnectionFactory... factories)
|
||||
{
|
||||
this(server,null,null,null,0,0,AbstractConnectionFactory.getFactories(sslContextFactory,factories));
|
||||
this(server,null,null,null,-1,-1,AbstractConnectionFactory.getFactories(sslContextFactory,factories));
|
||||
}
|
||||
|
||||
/** Generic Server Connection.
|
||||
|
@ -189,9 +191,10 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
* @param bufferPool
|
||||
* A ByteBuffer pool used to allocate buffers. If null then create a private pool with default configuration.
|
||||
* @param acceptors
|
||||
* the number of acceptor threads to use, or 0 for a default value. Acceptors accept new TCP/IP connections.
|
||||
* the number of acceptor threads to use, or -1 for a default value. Acceptors accept new TCP/IP connections. If 0, then
|
||||
* the selector threads are used to accept connections.
|
||||
* @param selectors
|
||||
* the number of selector threads, or 0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||
* the number of selector threads, or -1 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||
* @param factories
|
||||
* Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
||||
*/
|
||||
|
@ -205,10 +208,22 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
@Name("factories") ConnectionFactory... factories)
|
||||
{
|
||||
super(server,executor,scheduler,bufferPool,acceptors,factories);
|
||||
_manager = new ServerConnectorManager(getExecutor(), getScheduler(), selectors > 0 ? selectors : Runtime.getRuntime().availableProcessors());
|
||||
_manager = new ServerConnectorManager(getExecutor(), getScheduler(), selectors >= 0 ? selectors : Runtime.getRuntime().availableProcessors());
|
||||
addBean(_manager, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
super.doStart();
|
||||
|
||||
if (getAcceptors()==0)
|
||||
{
|
||||
_acceptChannel.configureBlocking(false);
|
||||
_manager.acceptor(_acceptChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen()
|
||||
{
|
||||
|
@ -319,12 +334,17 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
if (serverChannel != null && serverChannel.isOpen())
|
||||
{
|
||||
SocketChannel channel = serverChannel.accept();
|
||||
channel.configureBlocking(false);
|
||||
Socket socket = channel.socket();
|
||||
configure(socket);
|
||||
_manager.accept(channel);
|
||||
accepted(channel);
|
||||
}
|
||||
}
|
||||
|
||||
private void accepted(SocketChannel channel) throws IOException
|
||||
{
|
||||
channel.configureBlocking(false);
|
||||
Socket socket = channel.socket();
|
||||
configure(socket);
|
||||
_manager.accept(channel);
|
||||
}
|
||||
|
||||
protected void configure(Socket socket)
|
||||
{
|
||||
|
@ -426,6 +446,12 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
super(executor, scheduler, selectors);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accepted(SocketChannel channel) throws IOException
|
||||
{
|
||||
ServerConnector.this.accepted(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey selectionKey) throws IOException
|
||||
{
|
||||
|
|
|
@ -25,9 +25,9 @@ import java.io.OutputStream;
|
|||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.thread.ShutdownThread;
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,7 @@ public class ShutdownMonitor
|
|||
|
||||
// Reply to client
|
||||
debug("Informing client that we are stopped.");
|
||||
out.write("Stopped\r\n".getBytes(StringUtil.__UTF8));
|
||||
out.write("Stopped\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
out.flush();
|
||||
|
||||
// Shutdown Monitor
|
||||
|
@ -131,7 +131,7 @@ public class ShutdownMonitor
|
|||
else if ("status".equals(cmd))
|
||||
{
|
||||
// Reply to client
|
||||
out.write("OK\r\n".getBytes(StringUtil.__UTF8));
|
||||
out.write("OK\r\n".getBytes(StandardCharsets.UTF_8));
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.PrintWriter;
|
|||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.activation.MimeType;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue