Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-multipartCleanups

This commit is contained in:
Lachlan Roberts 2023-02-08 11:55:37 +11:00
commit 6950d73fce
360 changed files with 3730 additions and 5404 deletions

View File

@ -58,7 +58,7 @@ The following fragment shows how to configure a top level statistics handler:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="insertHandler">
<Arg>
<New id="StatsHandler" class="org.eclipse.jetty.server.handler.StatisticsHandler"/>
<New id="StatisticsHandler" class="org.eclipse.jetty.server.handler.StatisticsHandler"/>
</Arg>
</Call>
</Configure>

View File

@ -33,7 +33,7 @@ The `ClientConnector` primarily wraps the link:{javadoc-url}/org/eclipse/jetty/i
* a thread pool (in form of an `java.util.concurrent.Executor`)
* a scheduler (in form of `org.eclipse.jetty.util.thread.Scheduler`)
* a byte buffer pool (in form of `org.eclipse.jetty.io.RetainableByteBufferPool`)
* a byte buffer pool (in form of `org.eclipse.jetty.io.ByteBufferPool`)
* a TLS factory (in form of `org.eclipse.jetty.util.ssl.SslContextFactory.Client`)
The `ClientConnector` is where you want to set those components after you have configured them.

View File

@ -243,7 +243,7 @@ Server applications can read these values and use them internally, or expose the
[source,java,indent=0]
----
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=statsHandler]
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=statisticsHandler]
----
The `Handler` tree structure looks like the following:
@ -258,6 +258,14 @@ Server
└── ContextHandler N
----
It is possible to act on those statistics by subclassing `StatisticsHandler`.
For instance, `StatisticsHandler.MinimumDataRateHandler` can be used to enforce a minimum read rate and a minimum write rate based of the figures collected by the `StatisticsHandler`:
[source,java,indent=0]
----
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=dataRateHandler]
----
[[pg-server-http-handler-use-util-secure-handler]]
====== SecuredRedirectHandler -- Redirect from HTTP to HTTPS

View File

@ -387,7 +387,7 @@ public class ClientConnectorDocs
// Wrap the "telnet" ClientConnectionFactory with the SslClientConnectionFactory.
connectionFactory = new SslClientConnectionFactory(clientConnector.getSslContextFactory(),
clientConnector.getRetainableByteBufferPool(), clientConnector.getExecutor(), connectionFactory);
clientConnector.getByteBufferPool(), clientConnector.getExecutor(), connectionFactory);
// We will obtain a SslConnection now.
CompletableFuture<SslConnection> connectionPromise = new Promise.Completable<>();

View File

@ -17,8 +17,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.CookieStore;
import java.net.HttpCookie;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.file.Path;
@ -54,6 +52,8 @@ import org.eclipse.jetty.client.transport.HttpClientConnectionFactory;
import org.eclipse.jetty.client.transport.HttpClientTransportDynamic;
import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP;
import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpCookieStore;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
@ -67,7 +67,6 @@ import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.HttpCookieStore;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.ssl.SslContextFactory;
@ -541,8 +540,8 @@ public class HTTPClientDocs
httpClient.start();
// tag::getCookies[]
CookieStore cookieStore = httpClient.getCookieStore();
List<HttpCookie> cookies = cookieStore.get(URI.create("http://domain.com/path"));
HttpCookieStore cookieStore = httpClient.getHttpCookieStore();
List<HttpCookie> cookies = cookieStore.match(URI.create("http://domain.com/path"));
// end::getCookies[]
}
@ -552,11 +551,12 @@ public class HTTPClientDocs
httpClient.start();
// tag::setCookie[]
CookieStore cookieStore = httpClient.getCookieStore();
HttpCookie cookie = new HttpCookie("foo", "bar");
cookie.setDomain("domain.com");
cookie.setPath("/");
cookie.setMaxAge(TimeUnit.DAYS.toSeconds(1));
HttpCookieStore cookieStore = httpClient.getHttpCookieStore();
HttpCookie cookie = HttpCookie.build("foo", "bar")
.domain("domain.com")
.path("/")
.maxAge(TimeUnit.DAYS.toSeconds(1))
.build();
cookieStore.add(URI.create("http://domain.com"), cookie);
// end::setCookie[]
}
@ -568,7 +568,7 @@ public class HTTPClientDocs
// tag::requestCookie[]
ContentResponse response = httpClient.newRequest("http://domain.com/path")
.cookie(new HttpCookie("foo", "bar"))
.cookie(HttpCookie.from("foo", "bar"))
.send();
// end::requestCookie[]
}
@ -579,9 +579,9 @@ public class HTTPClientDocs
httpClient.start();
// tag::removeCookie[]
CookieStore cookieStore = httpClient.getCookieStore();
HttpCookieStore cookieStore = httpClient.getHttpCookieStore();
URI uri = URI.create("http://domain.com");
List<HttpCookie> cookies = cookieStore.get(uri);
List<HttpCookie> cookies = cookieStore.match(uri);
for (HttpCookie cookie : cookies)
{
cookieStore.remove(uri, cookie);
@ -595,7 +595,7 @@ public class HTTPClientDocs
httpClient.start();
// tag::emptyCookieStore[]
httpClient.setCookieStore(new HttpCookieStore.Empty());
httpClient.setHttpCookieStore(new HttpCookieStore.Empty());
// end::emptyCookieStore[]
}
@ -605,17 +605,18 @@ public class HTTPClientDocs
httpClient.start();
// tag::filteringCookieStore[]
class GoogleOnlyCookieStore extends HttpCookieStore
class GoogleOnlyCookieStore extends HttpCookieStore.Default
{
@Override
public void add(URI uri, HttpCookie cookie)
public boolean add(URI uri, HttpCookie cookie)
{
if (uri.getHost().endsWith("google.com"))
super.add(uri, cookie);
return super.add(uri, cookie);
return false;
}
}
httpClient.setCookieStore(new GoogleOnlyCookieStore());
httpClient.setHttpCookieStore(new GoogleOnlyCookieStore());
// end::filteringCookieStore[]
}

View File

@ -189,7 +189,7 @@ public class HandlerDocs
}
}
public static class RootHandler extends Handler.Collection
public static class RootHandler extends Handler.Sequence
{
@Override
public boolean process(Request request, Response response, Callback callback) throws Exception

View File

@ -511,11 +511,11 @@ public class HTTPServerDocs
GzipHandler gzipHandler = new GzipHandler();
server.setHandler(gzipHandler);
Handler.Collection collection = new Handler.Collection();
gzipHandler.setHandler(collection);
Handler.Sequence sequence = new Handler.Sequence();
gzipHandler.setHandler(sequence);
collection.addHandler(new App1Handler());
collection.addHandler(new App2Handler());
sequence.addHandler(new App1Handler());
sequence.addHandler(new App2Handler());
// end::handlerTree[]
}
@ -927,9 +927,9 @@ public class HTTPServerDocs
// end::rewriteHandler[]
}
public void statsHandler() throws Exception
public void statisticsHandler() throws Exception
{
// tag::statsHandler[]
// tag::statisticsHandler[]
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
server.addConnector(connector);
@ -945,7 +945,29 @@ public class HTTPServerDocs
statsHandler.setHandler(contextCollection);
server.start();
// end::statsHandler[]
// end::statisticsHandler[]
}
public void dataRateHandler() throws Exception
{
// tag::dataRateHandler[]
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
server.addConnector(connector);
// Create the MinimumDataRateHandler with a minimum read rate of 1KB per second and no minimum write rate.
StatisticsHandler.MinimumDataRateHandler dataRateHandler = new StatisticsHandler.MinimumDataRateHandler(1024L, 0L);
// Link the MinimumDataRateHandler to the Server.
server.setHandler(dataRateHandler);
// Create a ContextHandlerCollection to hold contexts.
ContextHandlerCollection contextCollection = new ContextHandlerCollection();
// Link the ContextHandlerCollection to the MinimumDataRateHandler.
dataRateHandler.setHandler(contextCollection);
server.start();
// end::dataRateHandler[]
}
public void securedHandler() throws Exception

View File

@ -52,7 +52,7 @@ public abstract class AbstractConnectorHttpClientTransport extends AbstractHttpC
{
HttpClient httpClient = getHttpClient();
connector.setBindAddress(httpClient.getBindAddress());
connector.setRetainableByteBufferPool(httpClient.getRetainableByteBufferPool());
connector.setByteBufferPool(httpClient.getByteBufferPool());
connector.setConnectBlocking(httpClient.isConnectBlocking());
connector.setConnectTimeout(Duration.ofMillis(httpClient.getConnectTimeout()));
connector.setExecutor(httpClient.getExecutor());

View File

@ -13,8 +13,8 @@
package org.eclipse.jetty.client;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
/**
* {@link ContentDecoder} for the "gzip" encoding.
@ -33,9 +33,9 @@ public class GZIPContentDecoder extends org.eclipse.jetty.http.GZIPContentDecode
this(null, bufferSize);
}
public GZIPContentDecoder(RetainableByteBufferPool retainableByteBufferPool, int bufferSize)
public GZIPContentDecoder(ByteBufferPool byteBufferPool, int bufferSize)
{
super(retainableByteBufferPool, bufferSize);
super(byteBufferPool, bufferSize);
}
@Override
@ -50,7 +50,7 @@ public class GZIPContentDecoder extends org.eclipse.jetty.http.GZIPContentDecode
*/
public static class Factory extends ContentDecoder.Factory
{
private final RetainableByteBufferPool retainableByteBufferPool;
private final ByteBufferPool byteBufferPool;
private final int bufferSize;
public Factory()
@ -63,22 +63,22 @@ public class GZIPContentDecoder extends org.eclipse.jetty.http.GZIPContentDecode
this(null, bufferSize);
}
public Factory(RetainableByteBufferPool retainableByteBufferPool)
public Factory(ByteBufferPool byteBufferPool)
{
this(retainableByteBufferPool, DEFAULT_BUFFER_SIZE);
this(byteBufferPool, DEFAULT_BUFFER_SIZE);
}
public Factory(RetainableByteBufferPool retainableByteBufferPool, int bufferSize)
public Factory(ByteBufferPool byteBufferPool, int bufferSize)
{
super("gzip");
this.retainableByteBufferPool = retainableByteBufferPool;
this.byteBufferPool = byteBufferPool;
this.bufferSize = bufferSize;
}
@Override
public ContentDecoder newContentDecoder()
{
return new GZIPContentDecoder(retainableByteBufferPool, bufferSize);
return new GZIPContentDecoder(byteBufferPool, bufferSize);
}
}
}

View File

@ -43,15 +43,17 @@ import org.eclipse.jetty.client.transport.HttpConversation;
import org.eclipse.jetty.client.transport.HttpDestination;
import org.eclipse.jetty.client.transport.HttpRequest;
import org.eclipse.jetty.http.HttpCompliance;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpCookieStore;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.Fields;
import org.eclipse.jetty.util.Jetty;
@ -81,7 +83,7 @@ import org.slf4j.LoggerFactory;
* and HTTP parameters (such as whether to follow redirects).</p>
* <p>HttpClient transparently pools connections to servers, but allows direct control of connections
* for cases where this is needed.</p>
* <p>HttpClient also acts as a central configuration point for cookies, via {@link #getCookieStore()}.</p>
* <p>HttpClient also acts as a central configuration point for cookies, via {@link #getHttpCookieStore()}.</p>
* <p>Typical usage:</p>
* <pre>
* HttpClient httpClient = new HttpClient();
@ -121,8 +123,8 @@ public class HttpClient extends ContainerLifeCycle
private final HttpClientTransport transport;
private final ClientConnector connector;
private AuthenticationStore authenticationStore = new HttpAuthenticationStore();
private CookieManager cookieManager;
private CookieStore cookieStore;
private HttpCookieStore cookieStore;
private HttpCookieParser cookieParser;
private SocketAddressResolver resolver;
private HttpField agentField = new HttpField(HttpHeader.USER_AGENT, USER_AGENT);
private boolean followRedirects = true;
@ -199,9 +201,9 @@ public class HttpClient extends ContainerLifeCycle
int maxBucketSize = executor instanceof ThreadPool.SizedThreadPool
? ((ThreadPool.SizedThreadPool)executor).getMaxThreads() / 2
: ProcessorUtils.availableProcessors() * 2;
RetainableByteBufferPool retainableByteBufferPool = getRetainableByteBufferPool();
if (retainableByteBufferPool == null)
setRetainableByteBufferPool(new ArrayRetainableByteBufferPool(0, 2048, 65536, maxBucketSize));
ByteBufferPool byteBufferPool = getByteBufferPool();
if (byteBufferPool == null)
setByteBufferPool(new ArrayByteBufferPool(0, 2048, 65536, maxBucketSize));
Scheduler scheduler = getScheduler();
if (scheduler == null)
{
@ -220,10 +222,11 @@ public class HttpClient extends ContainerLifeCycle
handlers.put(new ProxyAuthenticationProtocolHandler(this));
handlers.put(new UpgradeProtocolHandler());
decoderFactories.put(new GZIPContentDecoder.Factory(retainableByteBufferPool));
decoderFactories.put(new GZIPContentDecoder.Factory(byteBufferPool));
cookieManager = newCookieManager();
cookieStore = cookieManager.getCookieStore();
if (cookieStore == null)
cookieStore = new HttpCookieStore.Default();
cookieParser = new HttpCookieParser();
transport.setHttpClient(this);
@ -236,11 +239,6 @@ public class HttpClient extends ContainerLifeCycle
}
}
private CookieManager newCookieManager()
{
return new CookieManager(getCookieStore(), CookiePolicy.ACCEPT_ALL);
}
@Override
protected void doStop() throws Exception
{
@ -274,7 +272,7 @@ public class HttpClient extends ContainerLifeCycle
/**
* @return the cookie store associated with this instance
*/
public CookieStore getCookieStore()
public HttpCookieStore getHttpCookieStore()
{
return cookieStore;
}
@ -282,25 +280,20 @@ public class HttpClient extends ContainerLifeCycle
/**
* @param cookieStore the cookie store associated with this instance
*/
public void setCookieStore(CookieStore cookieStore)
public void setHttpCookieStore(HttpCookieStore cookieStore)
{
if (isStarted())
throw new IllegalStateException();
this.cookieStore = Objects.requireNonNull(cookieStore);
this.cookieManager = newCookieManager();
}
public void putCookie(URI uri, HttpField field)
{
try
{
String value = field.getValue();
if (value != null)
{
Map<String, List<String>> header = new HashMap<>(1);
header.put(field.getHeader().asString(), List.of(value));
cookieManager.put(uri, header);
}
HttpCookie cookie = cookieParser.parse(uri, field);
if (cookie != null)
cookieStore.add(uri, cookie);
}
catch (IOException x)
{
@ -646,19 +639,19 @@ public class HttpClient extends ContainerLifeCycle
}
/**
* @return the {@link RetainableByteBufferPool} of this HttpClient
* @return the {@link ByteBufferPool} of this HttpClient
*/
public RetainableByteBufferPool getRetainableByteBufferPool()
public ByteBufferPool getByteBufferPool()
{
return connector.getRetainableByteBufferPool();
return connector.getByteBufferPool();
}
/**
* @param retainableByteBufferPool the {@link RetainableByteBufferPool} of this HttpClient
* @param byteBufferPool the {@link ByteBufferPool} of this HttpClient
*/
public void setRetainableByteBufferPool(RetainableByteBufferPool retainableByteBufferPool)
public void setByteBufferPool(ByteBufferPool byteBufferPool)
{
connector.setRetainableByteBufferPool(retainableByteBufferPool);
connector.setByteBufferPool(byteBufferPool);
}
/**
@ -1138,20 +1131,77 @@ public class HttpClient extends ContainerLifeCycle
return HttpScheme.getDefaultPort(scheme);
}
public boolean isDefaultPort(String scheme, int port)
{
return HttpScheme.getDefaultPort(scheme) == port;
}
public static boolean isSchemeSecure(String scheme)
{
return HttpScheme.HTTPS.is(scheme) || HttpScheme.WSS.is(scheme);
}
public ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory)
{
if (sslContextFactory == null)
sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory);
return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory);
}
private static class HttpCookieParser extends CookieManager
{
public HttpCookieParser()
{
super(new Store(), CookiePolicy.ACCEPT_ALL);
}
public HttpCookie parse(URI uri, HttpField field) throws IOException
{
// TODO: hacky implementation waiting for a real HttpCookie parser.
String value = field.getValue();
if (value == null)
return null;
Map<String, List<String>> header = new HashMap<>(1);
header.put(field.getHeader().asString(), List.of(value));
put(uri, header);
Store store = (Store)getCookieStore();
HttpCookie cookie = store.cookie;
store.cookie = null;
return cookie;
}
private static class Store implements CookieStore
{
private HttpCookie cookie;
@Override
public void add(URI uri, java.net.HttpCookie cookie)
{
String domain = cookie.getDomain();
if ("localhost.local".equals(domain))
cookie.setDomain("localhost");
this.cookie = HttpCookie.from(cookie);
}
@Override
public List<java.net.HttpCookie> get(URI uri)
{
throw new UnsupportedOperationException();
}
@Override
public List<java.net.HttpCookie> getCookies()
{
throw new UnsupportedOperationException();
}
@Override
public List<URI> getURIs()
{
throw new UnsupportedOperationException();
}
@Override
public boolean remove(URI uri, java.net.HttpCookie cookie)
{
throw new UnsupportedOperationException();
}
@Override
public boolean removeAll()
{
throw new UnsupportedOperationException();
}
}
}
}

View File

@ -15,7 +15,7 @@ package org.eclipse.jetty.client;
import java.io.InputStream;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.content.InputStreamContentSource;
/**
@ -51,7 +51,7 @@ public class InputStreamRequestContent extends InputStreamContentSource implemen
this(contentType, stream, null);
}
public InputStreamRequestContent(String contentType, InputStream stream, RetainableByteBufferPool bufferPool)
public InputStreamRequestContent(String contentType, InputStream stream, ByteBufferPool bufferPool)
{
super(stream, bufferPool);
this.contentType = contentType;

View File

@ -16,14 +16,14 @@ package org.eclipse.jetty.client;
import java.io.IOException;
import java.nio.file.Path;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.content.PathContentSource;
/**
* <p>A {@link Request.Content} for files using JDK 7's {@code java.nio.file} APIs.</p>
* <p>It is possible to specify a buffer size used to read content from the stream,
* by default 4096 bytes, whether the buffer should be direct or not, and a
* {@link RetainableByteBufferPool} from which {@code ByteBuffer}s will be acquired
* {@link ByteBufferPool} from which {@code ByteBuffer}s will be acquired
* to read from the {@code Path}.</p>
*/
public class PathRequestContent extends PathContentSource implements Request.Content
@ -51,7 +51,7 @@ public class PathRequestContent extends PathContentSource implements Request.Con
setBufferSize(bufferSize);
}
public PathRequestContent(String contentType, Path filePath, RetainableByteBufferPool bufferPool) throws IOException
public PathRequestContent(String contentType, Path filePath, ByteBufferPool bufferPool) throws IOException
{
super(filePath, bufferPool);
this.contentType = contentType;

View File

@ -14,7 +14,6 @@
package org.eclipse.jetty.client;
import java.io.IOException;
import java.net.HttpCookie;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
@ -30,6 +29,7 @@ import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpVersion;

View File

@ -28,12 +28,12 @@ import org.eclipse.jetty.alpn.client.ALPNClientConnection;
import org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory;
import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport;
import org.eclipse.jetty.client.Destination;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.MultiplexConnectionPool;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
@ -130,7 +130,8 @@ public class HttpClientTransportDynamic extends AbstractConnectorHttpClientTrans
@Override
public Origin newOrigin(Request request)
{
boolean secure = HttpClient.isSchemeSecure(request.getScheme());
String scheme = request.getScheme();
boolean secure = HttpScheme.isSecure(scheme);
String http1 = "http/1.1";
String http2 = secure ? "h2" : "h2c";
List<String> protocols = List.of();

View File

@ -13,8 +13,6 @@
package org.eclipse.jetty.client.transport;
import java.net.CookieStore;
import java.net.HttpCookie;
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
@ -30,13 +28,15 @@ import org.eclipse.jetty.client.HttpRequestException;
import org.eclipse.jetty.client.ProxyConfiguration;
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.client.Response;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpCookieStore;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.CyclicTimeouts;
import org.eclipse.jetty.util.Attachable;
import org.eclipse.jetty.util.HttpCookieStore;
import org.eclipse.jetty.util.NanoTime;
import org.eclipse.jetty.util.thread.AutoLock;
import org.eclipse.jetty.util.thread.Scheduler;
@ -156,13 +156,17 @@ public abstract class HttpConnection implements IConnection, Attachable
}
ProxyConfiguration.Proxy proxy = destination.getProxy();
if (proxy instanceof HttpProxy && !HttpClient.isSchemeSecure(request.getScheme()))
if (proxy instanceof HttpProxy)
{
URI uri = request.getURI();
if (uri != null)
String scheme = request.getScheme();
if (!HttpScheme.isSecure(scheme))
{
path = uri.toString();
request.path(path);
URI uri = request.getURI();
if (uri != null)
{
path = uri.toString();
request.path(path);
}
}
}
@ -210,12 +214,12 @@ public abstract class HttpConnection implements IConnection, Attachable
// Cookies
StringBuilder cookies = convertCookies(request.getCookies(), null);
CookieStore cookieStore = getHttpClient().getCookieStore();
HttpCookieStore cookieStore = getHttpClient().getHttpCookieStore();
if (cookieStore != null && cookieStore.getClass() != HttpCookieStore.Empty.class)
{
URI uri = request.getURI();
if (uri != null)
cookies = convertCookies(HttpCookieStore.matchPath(uri, cookieStore.get(uri)), cookies);
cookies = convertCookies(cookieStore.match(uri), cookies);
}
if (cookies != null)
{

View File

@ -32,6 +32,7 @@ import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.client.Response;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.CyclicTimeouts;
import org.eclipse.jetty.util.BlockingArrayQueue;
@ -84,8 +85,9 @@ public class HttpDestination extends ContainerLifeCycle implements Destination,
this.requestTimeouts = new RequestTimeouts(client.getScheduler());
String host = HostPort.normalizeHost(getHost());
if (!client.isDefaultPort(getScheme(), getPort()))
host += ":" + getPort();
int port = getPort();
if (port != HttpScheme.getDefaultPort(getScheme()))
host += ":" + port;
hostField = new HttpField(HttpHeader.HOST, host);
ProxyConfiguration proxyConfig = client.getProxyConfiguration();
@ -199,7 +201,7 @@ public class HttpDestination extends ContainerLifeCycle implements Destination,
@Override
public boolean isSecure()
{
return HttpClient.isSchemeSecure(getScheme());
return HttpScheme.isSecure(getScheme());
}
@Override

View File

@ -14,7 +14,6 @@
package org.eclipse.jetty.client.transport;
import java.io.IOException;
import java.net.HttpCookie;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
@ -48,6 +47,7 @@ import org.eclipse.jetty.client.PathRequestContent;
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.client.Response;
import org.eclipse.jetty.client.Result;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;

View File

@ -30,10 +30,10 @@ import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Promise;
import org.slf4j.Logger;
@ -45,7 +45,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
private final LongAdder inMessages = new LongAdder();
private final HttpParser parser;
private final RetainableByteBufferPool retainableByteBufferPool;
private final ByteBufferPool byteBufferPool;
private RetainableByteBuffer networkBuffer;
private boolean shutdown;
private boolean complete;
@ -66,7 +66,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
parser.setHeaderCacheSize(httpTransport.getHeaderCacheSize());
parser.setHeaderCacheCaseSensitive(httpTransport.isHeaderCacheCaseSensitive());
}
retainableByteBufferPool = httpClient.getRetainableByteBufferPool();
byteBufferPool = httpClient.getByteBufferPool();
}
void receive()
@ -197,7 +197,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
{
HttpClient client = getHttpDestination().getHttpClient();
boolean direct = client.isUseInputDirectByteBuffers();
return retainableByteBufferPool.acquire(client.getResponseBufferSize(), direct);
return byteBufferPool.acquire(client.getResponseBufferSize(), direct);
}
private void releaseNetworkBuffer()

View File

@ -23,10 +23,10 @@ import org.eclipse.jetty.client.transport.HttpSender;
import org.eclipse.jetty.http.HttpGenerator;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IteratingCallback;
@ -158,7 +158,7 @@ public class HttpSenderOverHTTP extends HttpSender
protected Action process() throws Exception
{
HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient();
RetainableByteBufferPool bufferPool = httpClient.getRetainableByteBufferPool();
ByteBufferPool bufferPool = httpClient.getByteBufferPool();
boolean useDirectByteBuffers = httpClient.isUseOutputDirectByteBuffers();
while (true)
{
@ -289,7 +289,7 @@ public class HttpSenderOverHTTP extends HttpSender
protected Action process() throws Exception
{
HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient();
RetainableByteBufferPool bufferPool = httpClient.getRetainableByteBufferPool();
ByteBufferPool bufferPool = httpClient.getByteBufferPool();
boolean useDirectByteBuffers = httpClient.isUseOutputDirectByteBuffers();
while (true)
{

View File

@ -27,9 +27,9 @@ import java.util.zip.GZIPOutputStream;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.Callback;
@ -242,9 +242,9 @@ public class HttpClientGZIPTest extends AbstractHttpClientServerTest
}
});
RetainableByteBufferPool pool = client.getRetainableByteBufferPool();
assumeTrue(pool instanceof ArrayRetainableByteBufferPool);
ArrayRetainableByteBufferPool bufferPool = (ArrayRetainableByteBufferPool)pool;
ByteBufferPool pool = client.getByteBufferPool();
assumeTrue(pool instanceof ArrayByteBufferPool);
ArrayByteBufferPool bufferPool = (ArrayByteBufferPool)pool;
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.scheme(scenario.getScheme())

View File

@ -44,14 +44,14 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ConnectionStatistics;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.io.ssl.SslHandshakeListener;
@ -630,7 +630,7 @@ public class HttpClientTLSTest
@Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{
return new SslConnection(connector.getRetainableByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@Override
protected int networkFill(ByteBuffer input) throws IOException
@ -664,10 +664,10 @@ public class HttpClientTLSTest
{
if (sslContextFactory == null)
sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory)
return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory)
{
@Override
protected SslConnection newSslConnection(RetainableByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
protected SslConnection newSslConnection(ByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
{
return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@ -721,7 +721,7 @@ public class HttpClientTLSTest
@Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool();
ByteBufferPool bufferPool = connector.getByteBufferPool();
return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@Override
@ -753,7 +753,7 @@ public class HttpClientTLSTest
assertThrows(Exception.class, () -> client.newRequest("localhost", connector.getLocalPort()).scheme(HttpScheme.HTTPS.asString()).send());
ArrayRetainableByteBufferPool bufferPool = (ArrayRetainableByteBufferPool)server.getRetainableByteBufferPool();
ArrayByteBufferPool bufferPool = (ArrayByteBufferPool)server.getByteBufferPool();
Pool<RetainableByteBuffer> bucket = bufferPool.poolFor(16 * 1024 + 1, connector.getConnectionFactory(HttpConnectionFactory.class).isUseInputDirectByteBuffers());
assertEquals(1, bucket.size());
assertEquals(1, bucket.getIdleCount());
@ -769,7 +769,7 @@ public class HttpClientTLSTest
QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server");
List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>();
RetainableByteBufferPool bufferPool = new RetainableByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool())
ByteBufferPool bufferPool = new ByteBufferPool.Wrapper(new ArrayByteBufferPool())
{
@Override
public RetainableByteBuffer acquire(int size, boolean direct)
@ -798,7 +798,7 @@ public class HttpClientTLSTest
@Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool();
ByteBufferPool bufferPool = connector.getByteBufferPool();
return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@Override
@ -839,7 +839,7 @@ public class HttpClientTLSTest
QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server");
List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>();
RetainableByteBufferPool bufferPool = new RetainableByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool())
ByteBufferPool bufferPool = new ByteBufferPool.Wrapper(new ArrayByteBufferPool())
{
@Override
public RetainableByteBuffer acquire(int size, boolean direct)
@ -869,7 +869,7 @@ public class HttpClientTLSTest
@Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool();
ByteBufferPool bufferPool = connector.getByteBufferPool();
return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@Override
@ -924,7 +924,7 @@ public class HttpClientTLSTest
QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server");
List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>();
RetainableByteBufferPool bufferPool = new RetainableByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool())
ByteBufferPool bufferPool = new ByteBufferPool.Wrapper(new ArrayByteBufferPool())
{
@Override
public RetainableByteBuffer acquire(int size, boolean direct)
@ -954,7 +954,7 @@ public class HttpClientTLSTest
@Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool();
ByteBufferPool bufferPool = connector.getByteBufferPool();
return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@Override
@ -1017,7 +1017,7 @@ public class HttpClientTLSTest
@Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{
return new SslConnection(connector.getRetainableByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@Override
protected int networkFill(ByteBuffer input) throws IOException
@ -1052,10 +1052,10 @@ public class HttpClientTLSTest
{
if (sslContextFactory == null)
sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory)
return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory)
{
@Override
protected SslConnection newSslConnection(RetainableByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
protected SslConnection newSslConnection(ByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
{
return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@ -1114,10 +1114,10 @@ public class HttpClientTLSTest
{
if (sslContextFactory == null)
sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory)
return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory)
{
@Override
protected SslConnection newSslConnection(RetainableByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
protected SslConnection newSslConnection(ByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
{
return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@ -1158,7 +1158,7 @@ public class HttpClientTLSTest
@Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{
return new SslConnection(connector.getRetainableByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{
@Override
protected SSLEngineResult unwrap(SSLEngine sslEngine, ByteBuffer input, ByteBuffer output) throws SSLException
@ -1194,10 +1194,10 @@ public class HttpClientTLSTest
{
if (sslContextFactory == null)
sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory)
return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory)
{
@Override
protected SslConnection newSslConnection(RetainableByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
protected SslConnection newSslConnection(ByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
{
return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{

View File

@ -17,7 +17,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpCookie;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
@ -48,6 +47,7 @@ import org.eclipse.jetty.client.transport.HttpDestination;
import org.eclipse.jetty.client.transport.HttpRequest;
import org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP;
import org.eclipse.jetty.http.BadMessageException;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
@ -122,7 +122,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
Origin origin = destination.getOrigin();
String uri = origin.getScheme() + "://" + origin.getAddress();
client.getCookieStore().add(URI.create(uri), new HttpCookie("foo", "bar"));
client.getHttpCookieStore().add(URI.create(uri), HttpCookie.from("foo", "bar"));
client.stop();

View File

@ -13,8 +13,6 @@
package org.eclipse.jetty.client;
import java.net.CookieStore;
import java.net.HttpCookie;
import java.net.URI;
import java.util.Arrays;
import java.util.HashSet;
@ -23,9 +21,10 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpCookieStore;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.HttpCookieStore;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource;
@ -49,7 +48,7 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
@Override
protected void service(Request request, org.eclipse.jetty.server.Response response)
{
org.eclipse.jetty.server.Response.addCookie(response, org.eclipse.jetty.http.HttpCookie.from(name, value));
org.eclipse.jetty.server.Response.addCookie(response, HttpCookie.from(name, value));
}
});
@ -60,7 +59,7 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
Response response = client.GET(uri);
assertEquals(200, response.getStatus());
List<HttpCookie> cookies = client.getCookieStore().get(URI.create(uri));
List<HttpCookie> cookies = client.getHttpCookieStore().match(URI.create(uri));
assertNotNull(cookies);
assertEquals(1, cookies.size());
HttpCookie cookie = cookies.get(0);
@ -79,10 +78,10 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
@Override
protected void service(Request request, org.eclipse.jetty.server.Response response)
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
assertNotNull(cookies);
assertEquals(1, cookies.size());
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(name, cookie.getName());
assertEquals(value, cookie.getValue());
}
@ -92,8 +91,8 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int port = connector.getLocalPort();
String path = "/path";
String uri = scenario.getScheme() + "://" + host + ":" + port;
HttpCookie cookie = new HttpCookie(name, value);
client.getCookieStore().add(URI.create(uri), cookie);
HttpCookie cookie = HttpCookie.from(name, value);
client.getHttpCookieStore().add(URI.create(uri), cookie);
Response response = client.GET(scenario.getScheme() + "://" + host + ":" + port + path);
assertEquals(200, response.getStatus());
@ -116,7 +115,7 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
.scheme(scenario.getScheme())
.send();
assertEquals(200, response.getStatus());
assertTrue(client.getCookieStore().getCookies().isEmpty());
assertTrue(client.getHttpCookieStore().all().isEmpty());
}
@ParameterizedTest
@ -133,7 +132,7 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
testPerRequestCookieIsSent(scenario, new HttpCookieStore.Empty());
}
private void testPerRequestCookieIsSent(Scenario scenario, CookieStore cookieStore) throws Exception
private void testPerRequestCookieIsSent(Scenario scenario, HttpCookieStore cookieStore) throws Exception
{
final String name = "foo";
final String value = "bar";
@ -142,10 +141,10 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
@Override
protected void service(Request request, org.eclipse.jetty.server.Response response)
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
assertNotNull(cookies);
assertEquals(1, cookies.size());
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(name, cookie.getName());
assertEquals(value, cookie.getValue());
}
@ -153,12 +152,12 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
startClient(scenario, client ->
{
if (cookieStore != null)
client.setCookieStore(cookieStore);
client.setHttpCookieStore(cookieStore);
});
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.scheme(scenario.getScheme())
.cookie(new HttpCookie(name, value))
.cookie(HttpCookie.from(name, value))
.timeout(5, TimeUnit.SECONDS)
.send();
assertEquals(200, response.getStatus());
@ -180,18 +179,18 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int r = (int)request.getHeaders().getLongField(headerName);
if ("/foo".equals(target) && r == 0)
{
org.eclipse.jetty.http.HttpCookie cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue);
HttpCookie cookie = HttpCookie.from(cookieName, cookieValue);
org.eclipse.jetty.server.Response.addCookie(response, cookie);
}
else
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
switch (target)
{
case "/", "/foo", "/foo/bar" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(cookieName, cookie.getName(), target);
assertEquals(cookieValue, cookie.getValue(), target);
}
@ -235,19 +234,19 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int r = (int)request.getHeaders().getLongField(headerName);
if ("/foo/bar".equals(target) && r == 0)
{
org.eclipse.jetty.http.HttpCookie cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue);
HttpCookie cookie = HttpCookie.from(cookieName, cookieValue);
org.eclipse.jetty.server.Response.addCookie(response, cookie);
}
else
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
switch (target)
{
case "/", "/foo", "/foobar" -> assertEquals(0, cookies.size(), target);
case "/foo/", "/foo/bar", "/foo/bar/baz" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(cookieName, cookie.getName(), target);
assertEquals(cookieValue, cookie.getValue(), target);
}
@ -291,19 +290,19 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int r = (int)request.getHeaders().getLongField(headerName);
if ("/foo".equals(target) && r == 0)
{
org.eclipse.jetty.http.HttpCookie cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/foo/bar"));
HttpCookie cookie = HttpCookie.from(cookieName, cookieValue, Map.of(HttpCookie.PATH_ATTRIBUTE, "/foo/bar"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
}
else
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
switch (target)
{
case "/", "/foo", "/foo/barbaz" -> assertEquals(0, cookies.size(), target);
case "/foo/bar", "/foo/bar/" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(cookieName, cookie.getName(), target);
assertEquals(cookieValue, cookie.getValue(), target);
}
@ -347,19 +346,19 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int r = (int)request.getHeaders().getLongField(headerName);
if ("/foo/bar".equals(target) && r == 0)
{
org.eclipse.jetty.http.HttpCookie cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/foo"));
HttpCookie cookie = HttpCookie.from(cookieName, cookieValue, Map.of(HttpCookie.PATH_ATTRIBUTE, "/foo"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
}
else
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
switch (target)
{
case "/", "/foobar" -> assertEquals(0, cookies.size(), target);
case "/foo", "/foo/", "/foo/bar" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(cookieName, cookie.getName(), target);
assertEquals(cookieValue, cookie.getValue(), target);
}
@ -404,21 +403,21 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int r = (int)request.getHeaders().getLongField(headerName);
if ("/foo".equals(target) && r == 0)
{
org.eclipse.jetty.http.HttpCookie cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue1, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/foo"));
HttpCookie cookie = HttpCookie.from(cookieName, cookieValue1, Map.of(HttpCookie.PATH_ATTRIBUTE, "/foo"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue2, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/foo"));
cookie = HttpCookie.from(cookieName, cookieValue2, Map.of(HttpCookie.PATH_ATTRIBUTE, "/foo"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
}
else
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
switch (target)
{
case "/" -> assertEquals(0, cookies.size(), target);
case "/foo", "/foo/bar" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(cookieName, cookie.getName(), target);
assertEquals(cookieValue2, cookie.getValue(), target);
}
@ -463,28 +462,28 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int r = (int)request.getHeaders().getLongField(headerName);
if ("/foo".equals(target) && r == 0)
{
org.eclipse.jetty.http.HttpCookie cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue1, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/foo"));
HttpCookie cookie = HttpCookie.from(cookieName, cookieValue1, Map.of(HttpCookie.PATH_ATTRIBUTE, "/foo"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue2, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/bar"));
cookie = HttpCookie.from(cookieName, cookieValue2, Map.of(HttpCookie.PATH_ATTRIBUTE, "/bar"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
}
else
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
switch (target)
{
case "/" -> assertEquals(0, cookies.size(), target);
case "/foo", "/foo/bar" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie1 = cookies.get(0);
HttpCookie cookie1 = cookies.get(0);
assertEquals(cookieName, cookie1.getName(), target);
assertEquals(cookieValue1, cookie1.getValue(), target);
}
case "/bar", "/bar/foo" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie2 = cookies.get(0);
HttpCookie cookie2 = cookies.get(0);
assertEquals(cookieName, cookie2.getName(), target);
assertEquals(cookieValue2, cookie2.getValue(), target);
}
@ -529,29 +528,29 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int r = (int)request.getHeaders().getLongField(headerName);
if ("/foo".equals(target) && r == 0)
{
org.eclipse.jetty.http.HttpCookie cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue1, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/foo"));
HttpCookie cookie = HttpCookie.from(cookieName, cookieValue1, Map.of(HttpCookie.PATH_ATTRIBUTE, "/foo"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue2, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/foo/bar"));
cookie = HttpCookie.from(cookieName, cookieValue2, Map.of(HttpCookie.PATH_ATTRIBUTE, "/foo/bar"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
}
else
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
switch (target)
{
case "/" -> assertEquals(0, cookies.size(), target);
case "/foo" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(cookieName, cookie.getName(), target);
assertEquals(cookieValue1, cookie.getValue(), target);
}
case "/foo/bar" ->
{
assertEquals(2, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie1 = cookies.get(0);
org.eclipse.jetty.http.HttpCookie cookie2 = cookies.get(1);
HttpCookie cookie1 = cookies.get(0);
HttpCookie cookie2 = cookies.get(1);
assertEquals(cookieName, cookie1.getName(), target);
assertEquals(cookieName, cookie2.getName(), target);
Set<String> values = new HashSet<>();
@ -599,19 +598,19 @@ public class HttpCookieTest extends AbstractHttpClientServerTest
int r = (int)request.getHeaders().getLongField(headerName);
if ("/foo/bar".equals(target) && r == 0)
{
org.eclipse.jetty.http.HttpCookie cookie = org.eclipse.jetty.http.HttpCookie.from(cookieName, cookieValue, Map.of(org.eclipse.jetty.http.HttpCookie.PATH_ATTRIBUTE, "/foo/"));
HttpCookie cookie = HttpCookie.from(cookieName, cookieValue, Map.of(HttpCookie.PATH_ATTRIBUTE, "/foo/"));
org.eclipse.jetty.server.Response.addCookie(response, cookie);
}
else
{
List<org.eclipse.jetty.http.HttpCookie> cookies = Request.getCookies(request);
List<HttpCookie> cookies = Request.getCookies(request);
switch (target)
{
case "/", "/foo", "/foobar" -> assertEquals(0, cookies.size(), target);
case "/foo/", "/foo/bar" ->
{
assertEquals(1, cookies.size(), target);
org.eclipse.jetty.http.HttpCookie cookie = cookies.get(0);
HttpCookie cookie = cookies.get(0);
assertEquals(cookieName, cookie.getName(), target);
assertEquals(cookieValue, cookie.getValue(), target);
}

View File

@ -19,10 +19,10 @@ import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLHandshakeException;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteArrayEndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.BufferUtil;
@ -43,7 +43,7 @@ public class SslConnectionTest
sslContextFactory.setKeyStorePassword("storepwd");
sslContextFactory.start();
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.start();
ByteArrayEndPoint endPoint = new ByteArrayEndPoint();

View File

@ -283,7 +283,7 @@ public class MultiPartRequestContentTest extends AbstractHttpClientServerTest
});
MultiPartRequestContent multiPart = new MultiPartRequestContent();
PathRequestContent content = new PathRequestContent(contentType, tmpPath, client.getRetainableByteBufferPool());
PathRequestContent content = new PathRequestContent(contentType, tmpPath, client.getByteBufferPool());
content.setUseDirectByteBuffers(client.isUseOutputDirectByteBuffers());
multiPart.addPart(new MultiPart.ContentSourcePart(name, tmpPath.getFileName().toString(), null, content));
multiPart.close();

View File

@ -24,9 +24,9 @@ import org.eclipse.jetty.fcgi.generator.Flusher;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.IdleTimeout;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise;
import org.slf4j.Logger;
@ -162,7 +162,7 @@ public class HttpChannelOverFCGI extends HttpChannel
release();
}
protected void flush(RetainableByteBufferPool.Accumulator accumulator, Callback callback)
protected void flush(ByteBufferPool.Accumulator accumulator, Callback callback)
{
flusher.flush(accumulator, callback);
}

View File

@ -42,10 +42,10 @@ import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.Attachable;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Promise;
@ -57,7 +57,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements IConne
{
private static final Logger LOG = LoggerFactory.getLogger(HttpConnectionOverFCGI.class);
private final RetainableByteBufferPool networkByteBufferPool;
private final ByteBufferPool networkByteBufferPool;
private final AutoLock lock = new AutoLock();
private final LinkedList<Integer> requests = new LinkedList<>();
private final AtomicBoolean closed = new AtomicBoolean();
@ -81,7 +81,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements IConne
this.parser = new ClientParser(new ResponseListener());
requests.addLast(0);
HttpClient client = destination.getHttpClient();
this.networkByteBufferPool = client.getRetainableByteBufferPool();
this.networkByteBufferPool = client.getByteBufferPool();
}
public HttpDestination getHttpDestination()

View File

@ -29,7 +29,7 @@ import org.eclipse.jetty.fcgi.generator.ClientGenerator;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Jetty;
import org.eclipse.jetty.util.StringUtil;
@ -42,7 +42,7 @@ public class HttpSenderOverFCGI extends HttpSender
{
super(channel);
HttpClient httpClient = channel.getHttpDestination().getHttpClient();
this.generator = new ClientGenerator(httpClient.getRetainableByteBufferPool(), httpClient.isUseOutputDirectByteBuffers());
this.generator = new ClientGenerator(httpClient.getByteBufferPool(), httpClient.isUseOutputDirectByteBuffers());
}
@Override
@ -98,7 +98,7 @@ public class HttpSenderOverFCGI extends HttpSender
HttpClientTransportOverFCGI transport = (HttpClientTransportOverFCGI)getHttpChannel().getHttpDestination().getHttpClient().getTransport();
transport.customize(request, fcgiHeaders);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
int id = getHttpChannel().getRequest();
if (contentBuffer.hasRemaining() || lastContent)
{
@ -117,7 +117,7 @@ public class HttpSenderOverFCGI extends HttpSender
{
if (contentBuffer.hasRemaining() || lastContent)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
int request = getHttpChannel().getRequest();
generator.generateRequestContent(accumulator, request, contentBuffer, lastContent);
getHttpChannel().flush(accumulator, callback);

View File

@ -22,8 +22,8 @@ import java.util.List;
import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class ClientGenerator extends Generator
@ -33,17 +33,17 @@ public class ClientGenerator extends Generator
// 0x7F_FF - 4 (the 4 is to make room for the name (or value) length).
public static final int MAX_PARAM_LENGTH = 0x7F_FF - 4;
public ClientGenerator(RetainableByteBufferPool bufferPool)
public ClientGenerator(ByteBufferPool bufferPool)
{
this(bufferPool, true);
}
public ClientGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers)
public ClientGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{
super(bufferPool, useDirectByteBuffers);
}
public void generateRequestHeaders(RetainableByteBufferPool.Accumulator accumulator, int request, HttpFields fields)
public void generateRequestHeaders(ByteBufferPool.Accumulator accumulator, int request, HttpFields fields)
{
request &= 0xFF_FF;
@ -79,7 +79,7 @@ public class ClientGenerator extends Generator
// One FCGI_BEGIN_REQUEST + N FCGI_PARAMS + one last FCGI_PARAMS
RetainableByteBuffer beginBuffer = getRetainableByteBufferPool().acquire(16, isUseDirectByteBuffers());
RetainableByteBuffer beginBuffer = getByteBufferPool().acquire(16, isUseDirectByteBuffers());
accumulator.append(beginBuffer);
ByteBuffer beginByteBuffer = beginBuffer.getByteBuffer();
BufferUtil.clearToFill(beginByteBuffer);
@ -95,7 +95,7 @@ public class ClientGenerator extends Generator
while (fieldsLength > 0)
{
int capacity = 8 + Math.min(maxCapacity, fieldsLength);
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(capacity, isUseDirectByteBuffers());
RetainableByteBuffer buffer = getByteBufferPool().acquire(capacity, isUseDirectByteBuffers());
accumulator.append(buffer);
ByteBuffer byteBuffer = buffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer);
@ -133,7 +133,7 @@ public class ClientGenerator extends Generator
BufferUtil.flipToFlush(byteBuffer, 0);
}
RetainableByteBuffer lastBuffer = getRetainableByteBufferPool().acquire(8, isUseDirectByteBuffers());
RetainableByteBuffer lastBuffer = getByteBufferPool().acquire(8, isUseDirectByteBuffers());
accumulator.append(lastBuffer);
ByteBuffer lastByteBuffer = lastBuffer.getByteBuffer();
BufferUtil.clearToFill(lastByteBuffer);
@ -159,7 +159,7 @@ public class ClientGenerator extends Generator
return length > 127 ? 4 : 1;
}
public void generateRequestContent(RetainableByteBufferPool.Accumulator accumulator, int request, ByteBuffer content, boolean lastContent)
public void generateRequestContent(ByteBufferPool.Accumulator accumulator, int request, ByteBuffer content, boolean lastContent)
{
generateContent(accumulator, request, content, lastContent, FCGI.FrameType.STDIN);
}

View File

@ -18,8 +18,8 @@ import java.util.ArrayDeque;
import java.util.List;
import java.util.Queue;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IteratingCallback;
import org.eclipse.jetty.util.thread.AutoLock;
@ -40,7 +40,7 @@ public class Flusher
this.endPoint = endPoint;
}
public void flush(RetainableByteBufferPool.Accumulator accumulator, Callback callback)
public void flush(ByteBufferPool.Accumulator accumulator, Callback callback)
{
offer(new Entry(accumulator, callback));
flushCallback.iterate();
@ -126,7 +126,7 @@ public class Flusher
}
}
private record Entry(RetainableByteBufferPool.Accumulator accumulator, Callback callback) implements Callback
private record Entry(ByteBufferPool.Accumulator accumulator, Callback callback) implements Callback
{
@Override
public void succeeded()

View File

@ -16,24 +16,24 @@ package org.eclipse.jetty.fcgi.generator;
import java.nio.ByteBuffer;
import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class Generator
{
public static final int MAX_CONTENT_LENGTH = 0xFF_FF;
private final RetainableByteBufferPool bufferPool;
private final ByteBufferPool bufferPool;
private final boolean useDirectByteBuffers;
public Generator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers)
public Generator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{
this.bufferPool = bufferPool;
this.useDirectByteBuffers = useDirectByteBuffers;
}
public RetainableByteBufferPool getRetainableByteBufferPool()
public ByteBufferPool getByteBufferPool()
{
return bufferPool;
}
@ -43,7 +43,7 @@ public class Generator
return useDirectByteBuffers;
}
protected void generateContent(RetainableByteBufferPool.Accumulator accumulator, int id, ByteBuffer content, boolean lastContent, FCGI.FrameType frameType)
protected void generateContent(ByteBufferPool.Accumulator accumulator, int id, ByteBuffer content, boolean lastContent, FCGI.FrameType frameType)
{
id &= 0xFF_FF;
@ -51,7 +51,7 @@ public class Generator
while (contentLength > 0 || lastContent)
{
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(8, isUseDirectByteBuffers());
RetainableByteBuffer buffer = getByteBufferPool().acquire(8, isUseDirectByteBuffers());
accumulator.append(buffer);
ByteBuffer byteBuffer = buffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer);

View File

@ -23,8 +23,8 @@ import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class ServerGenerator extends Generator
@ -35,18 +35,18 @@ public class ServerGenerator extends Generator
private final boolean sendStatus200;
public ServerGenerator(RetainableByteBufferPool bufferPool)
public ServerGenerator(ByteBufferPool bufferPool)
{
this(bufferPool, true, true);
}
public ServerGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers, boolean sendStatus200)
public ServerGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers, boolean sendStatus200)
{
super(bufferPool, useDirectByteBuffers);
this.sendStatus200 = sendStatus200;
}
public void generateResponseHeaders(RetainableByteBufferPool.Accumulator accumulator, int request, int code, String reason, HttpFields fields)
public void generateResponseHeaders(ByteBufferPool.Accumulator accumulator, int request, int code, String reason, HttpFields fields)
{
request &= 0xFF_FF;
@ -97,7 +97,7 @@ public class ServerGenerator extends Generator
generateContent(accumulator, request, byteBuffer, false, FCGI.FrameType.STDOUT);
}
public void generateResponseContent(RetainableByteBufferPool.Accumulator accumulator, int request, ByteBuffer content, boolean lastContent, boolean aborted)
public void generateResponseContent(ByteBufferPool.Accumulator accumulator, int request, ByteBuffer content, boolean lastContent, boolean aborted)
{
if (aborted)
{
@ -117,7 +117,7 @@ public class ServerGenerator extends Generator
private RetainableByteBuffer generateEndRequest(int request, boolean aborted)
{
request &= 0xFF_FF;
RetainableByteBuffer endRequestBuffer = getRetainableByteBufferPool().acquire(16, isUseDirectByteBuffers());
RetainableByteBuffer endRequestBuffer = getByteBufferPool().acquire(16, isUseDirectByteBuffers());
ByteBuffer byteBuffer = endRequestBuffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer);
byteBuffer.putInt(0x01_03_00_00 + request);

View File

@ -21,8 +21,8 @@ import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.fcgi.parser.ServerParser;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -59,9 +59,9 @@ public class ClientGeneratorTest
String longLongValue = new String(chars);
fields.put(new HttpField(longLongName, longLongValue));
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
ClientGenerator generator = new ClientGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
int id = 13;
generator.generateRequestHeaders(accumulator, id, fields);
@ -157,9 +157,9 @@ public class ClientGeneratorTest
{
ByteBuffer content = ByteBuffer.allocate(contentLength);
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
ClientGenerator generator = new ClientGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
int id = 13;
generator.generateRequestContent(accumulator, id, content, true);

View File

@ -22,8 +22,8 @@ import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.fcgi.generator.ServerGenerator;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -44,9 +44,9 @@ public class ClientParserTest
String contentTypeValue = "text/html;charset=utf-8";
fields.put(contentTypeName, contentTypeValue);
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
ServerGenerator generator = new ServerGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateResponseHeaders(accumulator, id, statusCode, statusMessage, fields);
// Use the fundamental theorem of arithmetic to test the results.
@ -108,9 +108,9 @@ public class ClientParserTest
HttpFields fields = HttpFields.build()
.put("Content-Length", "0");
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
ServerGenerator generator = new ServerGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateResponseHeaders(accumulator, id, 200, "OK", fields);
generator.generateResponseContent(accumulator, id, null, true, false);
@ -158,9 +158,9 @@ public class ClientParserTest
String contentTypeValue = String.valueOf(contentLength);
fields.put(contentTypeName, contentTypeValue);
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
ServerGenerator generator = new ServerGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateResponseHeaders(accumulator, id, code, "OK", fields);
generator.generateResponseContent(accumulator, id, content, true, false);
@ -209,9 +209,9 @@ public class ClientParserTest
String contentTypeValue = String.valueOf(contentLength);
fields.put(contentTypeName, contentTypeValue);
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
ServerGenerator generator = new ServerGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateResponseHeaders(accumulator, id, code, "OK", fields);
generator.generateResponseContent(accumulator, id, content, true, false);

View File

@ -316,7 +316,7 @@ public class FastCGIProxyHandler extends ProxyHandler.Reverse
// If the Host header is missing, add it.
if (!proxyToServerRequest.getHeaders().contains(HttpHeader.HOST))
{
if (!getHttpClient().isDefaultPort(scheme, serverPort))
if (serverPort != HttpScheme.getDefaultPort(scheme))
serverName += ":" + serverPort;
String host = serverName;
proxyToServerRequest.headers(headers -> headers

View File

@ -28,8 +28,8 @@ import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.HttpStream;
import org.eclipse.jetty.util.BufferUtil;
@ -229,7 +229,7 @@ public class HttpStreamOverFCGI implements HttpStream
{
if (last)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generateResponseContent(accumulator, true, BufferUtil.EMPTY_BUFFER);
flusher.flush(accumulator, callback);
}
@ -241,7 +241,7 @@ public class HttpStreamOverFCGI implements HttpStream
}
else
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generateResponseContent(accumulator, last, content);
flusher.flush(accumulator, callback);
}
@ -260,8 +260,8 @@ public class HttpStreamOverFCGI implements HttpStream
boolean shutdown = _shutdown = info.getFields().contains(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.asString());
RetainableByteBufferPool bufferPool = _generator.getRetainableByteBufferPool();
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool bufferPool = _generator.getByteBufferPool();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
Flusher flusher = _connection.getFlusher();
if (head)
{
@ -288,12 +288,12 @@ public class HttpStreamOverFCGI implements HttpStream
flusher.shutdown();
}
private void generateResponseHeaders(RetainableByteBufferPool.Accumulator accumulator, MetaData.Response info)
private void generateResponseHeaders(ByteBufferPool.Accumulator accumulator, MetaData.Response info)
{
_generator.generateResponseHeaders(accumulator, _id, info.getStatus(), info.getReason(), info.getFields());
}
private void generateResponseContent(RetainableByteBufferPool.Accumulator accumulator, boolean last, ByteBuffer buffer)
private void generateResponseContent(ByteBufferPool.Accumulator accumulator, boolean last, ByteBuffer buffer)
{
_generator.generateResponseContent(accumulator, _id, buffer, last, _aborted);
}

View File

@ -26,11 +26,11 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.ConnectionMetaData;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpChannel;
@ -48,7 +48,7 @@ public class ServerFCGIConnection extends AbstractConnection implements Connecti
private final HttpChannel.Factory httpChannelFactory = new HttpChannel.DefaultFactory();
private final Attributes attributes = new Lazy();
private final Connector connector;
private final RetainableByteBufferPool networkByteBufferPool;
private final ByteBufferPool networkByteBufferPool;
private final boolean sendStatus200;
private final Flusher flusher;
private final HttpConfiguration configuration;
@ -63,7 +63,7 @@ public class ServerFCGIConnection extends AbstractConnection implements Connecti
{
super(endPoint, connector.getExecutor());
this.connector = connector;
this.networkByteBufferPool = connector.getRetainableByteBufferPool();
this.networkByteBufferPool = connector.getByteBufferPool();
this.flusher = new Flusher(endPoint);
this.configuration = configuration;
this.sendStatus200 = sendStatus200;
@ -333,7 +333,7 @@ public class ServerFCGIConnection extends AbstractConnection implements Connecti
if (stream != null)
throw new UnsupportedOperationException("FastCGI Multiplexing");
HttpChannel channel = httpChannelFactory.newHttpChannel(ServerFCGIConnection.this);
ServerGenerator generator = new ServerGenerator(connector.getRetainableByteBufferPool(), isUseOutputDirectByteBuffers(), sendStatus200);
ServerGenerator generator = new ServerGenerator(connector.getByteBufferPool(), isUseOutputDirectByteBuffers(), sendStatus200);
stream = new HttpStreamOverFCGI(ServerFCGIConnection.this, generator, channel, request);
channel.setHttpStream(stream);
if (LOG.isDebugEnabled())

View File

@ -21,9 +21,9 @@ import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.LeakTrackingConnectionPool;
import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Server;
@ -38,8 +38,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
public abstract class AbstractHttpClientServerTest
{
private RetainableByteBufferPool serverBufferPool;
protected RetainableByteBufferPool clientBufferPool;
private ByteBufferPool serverBufferPool;
protected ByteBufferPool clientBufferPool;
private final AtomicLong connectionLeaks = new AtomicLong();
protected Server server;
protected ServerConnector connector;
@ -53,7 +53,7 @@ public abstract class AbstractHttpClientServerTest
server = new Server(serverThreads);
ServerFCGIConnectionFactory fcgiConnectionFactory = new ServerFCGIConnectionFactory(new HttpConfiguration());
// TODO: restore leak tracking.
serverBufferPool = new ArrayRetainableByteBufferPool();
serverBufferPool = new ArrayByteBufferPool();
connector = new ServerConnector(server, null, null, serverBufferPool,
1, Math.max(1, ProcessorUtils.availableProcessors() / 2), fcgiConnectionFactory);
server.addConnector(connector);
@ -67,8 +67,8 @@ public abstract class AbstractHttpClientServerTest
clientConnector.setExecutor(clientThreads);
// TODO: restore leak tracking.
if (clientBufferPool == null)
clientBufferPool = new ArrayRetainableByteBufferPool();
clientConnector.setRetainableByteBufferPool(clientBufferPool);
clientBufferPool = new ArrayByteBufferPool();
clientConnector.setByteBufferPool(clientBufferPool);
HttpClientTransport transport = new HttpClientTransportOverFCGI(clientConnector, "");
transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination())
{

View File

@ -70,30 +70,6 @@ public class DateGenerator
return formatDate(instant.toEpochMilli());
}
/**
* Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
*
* @param buf the buffer to put the formatted date into
* @param date the date in milliseconds
*/
public static void formatCookieDate(StringBuilder buf, long date)
{
__dateGenerator.get().doFormatCookieDate(buf, date);
}
/**
* Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
*
* @param date the date in milliseconds
* @return the formatted date
*/
public static String formatCookieDate(long date)
{
StringBuilder buf = new StringBuilder(28);
formatCookieDate(buf, date);
return buf.toString();
}
private final StringBuilder buf = new StringBuilder(32);
private final GregorianCalendar gc = new GregorianCalendar(__GMT);

View File

@ -20,8 +20,8 @@ import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import java.util.zip.ZipException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.compression.InflaterPool;
@ -37,7 +37,7 @@ public class GZIPContentDecoder implements Destroyable
private static final long UINT_MAX = 0xFFFFFFFFL;
private final List<RetainableByteBuffer> _inflateds = new ArrayList<>();
private final RetainableByteBufferPool _pool;
private final ByteBufferPool _pool;
private final int _bufferSize;
private InflaterPool.Entry _inflaterEntry;
private Inflater _inflater;
@ -57,17 +57,17 @@ public class GZIPContentDecoder implements Destroyable
this(null, bufferSize);
}
public GZIPContentDecoder(RetainableByteBufferPool retainableByteBufferPool, int bufferSize)
public GZIPContentDecoder(ByteBufferPool byteBufferPool, int bufferSize)
{
this(new InflaterPool(0, true), retainableByteBufferPool, bufferSize);
this(new InflaterPool(0, true), byteBufferPool, bufferSize);
}
public GZIPContentDecoder(InflaterPool inflaterPool, RetainableByteBufferPool retainableByteBufferPool, int bufferSize)
public GZIPContentDecoder(InflaterPool inflaterPool, ByteBufferPool byteBufferPool, int bufferSize)
{
_inflaterEntry = inflaterPool.acquire();
_inflater = _inflaterEntry.get();
_bufferSize = bufferSize;
_pool = retainableByteBufferPool != null ? retainableByteBufferPool : new RetainableByteBufferPool.NonPooling();
_pool = byteBufferPool != null ? byteBufferPool : new ByteBufferPool.NonPooling();
reset();
}

View File

@ -0,0 +1,388 @@
//
// ========================================================================
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.http;
import java.net.URI;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.eclipse.jetty.util.NanoTime;
import org.eclipse.jetty.util.thread.AutoLock;
/**
* <p>A container for {@link HttpCookie}s.</p>
* <p>HTTP cookies are stored along with a {@link URI} via {@link #add(URI, HttpCookie)}
* and retrieved via {@link #match(URI)}, which implements the path matching algorithm
* defined by <a href="https://www.rfc-editor.org/rfc/rfc6265">RFC 6265</a>.</p>
*/
public interface HttpCookieStore
{
/**
* <p>Adds a cookie to this store, if possible.</p>
* <p>The cookie may not be added for various reasons; for example,
* it may be already expired, or its domain attribute does not
* match that of the URI, etc.</p>
* <p>The cookie is associated with the given {@code URI}, so that
* a call to {@link #match(URI)} returns the cookie only if the
* URIs match.</p>
*
* @param uri the {@code URI} associated with the cookie
* @param cookie the cookie to add
* @return whether the cookie has been added
*/
public boolean add(URI uri, HttpCookie cookie);
/**
* @return all the cookies
*/
public List<HttpCookie> all();
/**
* <p>Returns the cookies that match the given {@code URI}.</p>
*
* @param uri the {@code URI} to match against
* @return a list of cookies that match the given {@code URI}
*/
public List<HttpCookie> match(URI uri);
/**
* <p>Removes the cookie associated with the given {@code URI}.</p>
*
* @param uri the {@code URI} associated with the cookie to remove
* @param cookie the cookie to remove
* @return whether the cookie has been removed
*/
public boolean remove(URI uri, HttpCookie cookie);
/**
* <p>Removes all the cookies from this store.</p>
*
* @return whether the store modified by this call
*/
public boolean clear();
/**
* <p>An implementation of {@link HttpCookieStore} that does not store any cookie.</p>
*/
public static class Empty implements HttpCookieStore
{
@Override
public boolean add(URI uri, HttpCookie cookie)
{
return false;
}
@Override
public List<HttpCookie> all()
{
return List.of();
}
@Override
public List<HttpCookie> match(URI uri)
{
return List.of();
}
@Override
public boolean remove(URI uri, HttpCookie cookie)
{
return false;
}
@Override
public boolean clear()
{
return false;
}
}
/**
* <p>A default implementation of {@link HttpCookieStore}.</p>
*/
public static class Default implements HttpCookieStore
{
private final AutoLock lock = new AutoLock();
private final Map<Key, List<HttpCookie>> cookies = new HashMap<>();
@Override
public boolean add(URI uri, HttpCookie cookie)
{
// TODO: reject if cookie size is too big?
boolean secure = HttpScheme.isSecure(uri.getScheme());
// Do not accept a secure cookie sent over an insecure channel.
if (cookie.isSecure() && !secure)
return false;
String cookieDomain = cookie.getDomain();
if (cookieDomain != null)
{
cookieDomain = cookieDomain.toLowerCase(Locale.ENGLISH);
if (cookieDomain.startsWith("."))
cookieDomain = cookieDomain.substring(1);
// RFC 6265 section 4.1.2.3, ignore Domain if ends with ".".
if (cookieDomain.endsWith("."))
cookieDomain = uri.getHost();
// Reject top-level domains.
// TODO: should also reject "top" domain such as co.uk, gov.au, etc.
if (!cookieDomain.contains("."))
{
if (!cookieDomain.equals("localhost"))
return false;
}
String domain = uri.getHost();
if (domain != null)
{
domain = domain.toLowerCase(Locale.ENGLISH);
// If uri.host==foo.example.com, only accept
// cookie.domain==(foo.example.com|example.com).
if (!domain.endsWith(cookieDomain))
return false;
int beforeMatch = domain.length() - cookieDomain.length() - 1;
if (beforeMatch >= 0 && domain.charAt(beforeMatch) != '.')
return false;
}
}
else
{
// No explicit cookie domain, use the origin domain.
cookieDomain = uri.getHost();
}
// Cookies are stored under their domain, so that:
// - add(sub.example.com, cookie[Domain]=null) => Key[domain=sub.example.com]
// - add(sub.example.com, cookie[Domain]=example.com) => Key[domain=example.com]
// This facilitates the matching algorithm.
Key key = new Key(uri.getScheme(), cookieDomain);
boolean[] result = new boolean[]{true};
try (AutoLock ignored = lock.lock())
{
cookies.compute(key, (k, v) ->
{
// RFC 6265, section 4.1.2.
// Evict an existing cookie with
// same name, domain and path.
if (v != null)
v.remove(cookie);
// Add only non-expired cookies.
if (cookie.isExpired())
{
result[0] = false;
return v == null || v.isEmpty() ? null : v;
}
if (v == null)
v = new ArrayList<>();
v.add(new Cookie(cookie));
return v;
});
}
return result[0];
}
@Override
public List<HttpCookie> all()
{
try (AutoLock ignored = lock.lock())
{
return cookies.values().stream()
.flatMap(Collection::stream)
.toList();
}
}
@Override
public List<HttpCookie> match(URI uri)
{
List<HttpCookie> result = new ArrayList<>();
String scheme = uri.getScheme();
boolean secure = HttpScheme.isSecure(scheme);
String uriDomain = uri.getHost();
String path = uri.getPath();
if (path == null || path.trim().isEmpty())
path = "/";
try (AutoLock ignored = lock.lock())
{
// Given the way cookies are stored in the Map, the matching
// algorithm starts with the URI domain and iterates chopping
// its subdomains, accumulating the results.
// For example, for uriDomain = sub.example.com, the cookies
// Map is accessed with the following Keys:
// - Key[domain=sub.example.com]
// - chop domain to example.com
// - Key[domain=example.com]
// - chop domain to com
// invalid domain, exit iteration.
String domain = uriDomain;
while (true)
{
Key key = new Key(scheme, domain);
List<HttpCookie> stored = cookies.get(key);
Iterator<HttpCookie> iterator = stored == null ? Collections.emptyIterator() : stored.iterator();
while (iterator.hasNext())
{
HttpCookie cookie = iterator.next();
// Check and remove expired cookies.
if (cookie.isExpired())
{
iterator.remove();
continue;
}
// Check whether the cookie is secure.
if (cookie.isSecure() && !secure)
continue;
// Match the domain.
if (!domainMatches(uriDomain, key.domain, cookie.getDomain()))
continue;
// Match the path.
if (!pathMatches(path, cookie.getPath()))
continue;
result.add(cookie);
}
int dot = domain.indexOf('.');
if (dot < 0)
break;
// Remove one subdomain.
domain = domain.substring(dot + 1);
// Exit if the top-level domain was reached.
if (domain.indexOf('.') < 0)
break;
}
}
return result;
}
private static boolean domainMatches(String uriDomain, String domain, String cookieDomain)
{
if (uriDomain == null)
return true;
if (domain != null)
domain = domain.toLowerCase(Locale.ENGLISH);
uriDomain = uriDomain.toLowerCase(Locale.ENGLISH);
if (cookieDomain != null)
cookieDomain = cookieDomain.toLowerCase(Locale.ENGLISH);
if (cookieDomain == null || cookieDomain.endsWith("."))
{
// RFC 6265, section 4.1.2.3.
// No cookie domain -> cookie sent only to origin server.
return uriDomain.equals(domain);
}
if (cookieDomain.startsWith("."))
cookieDomain = cookieDomain.substring(1);
if (uriDomain.endsWith(cookieDomain))
{
// The domain is the same as, or a subdomain of, the cookie domain.
int beforeMatch = uriDomain.length() - cookieDomain.length() - 1;
// Domains are the same.
if (beforeMatch == -1)
return true;
// Verify it is a proper subdomain such as bar.foo.com,
// not just a suffix of a domain such as bazfoo.com.
return uriDomain.charAt(beforeMatch) == '.';
}
return false;
}
private static boolean pathMatches(String path, String cookiePath)
{
if (cookiePath == null)
return true;
// RFC 6265, section 5.1.4, path matching algorithm.
if (path.equals(cookiePath))
return true;
if (path.startsWith(cookiePath))
return cookiePath.endsWith("/") || path.charAt(cookiePath.length()) == '/';
return false;
}
@Override
public boolean remove(URI uri, HttpCookie cookie)
{
Key key = new Key(uri.getScheme(), uri.getHost());
try (AutoLock ignored = lock.lock())
{
boolean[] result = new boolean[1];
cookies.compute(key, (k, v) ->
{
if (v == null)
return null;
boolean removed = v.remove(cookie);
result[0] = removed;
return v.isEmpty() ? null : v;
});
return result[0];
}
}
@Override
public boolean clear()
{
try (AutoLock ignored = lock.lock())
{
if (cookies.isEmpty())
return false;
cookies.clear();
return true;
}
}
private record Key(String scheme, String domain)
{
private Key(String scheme, String domain)
{
this.scheme = scheme;
this.domain = domain.toLowerCase(Locale.ENGLISH);
}
}
private static class Cookie extends HttpCookie.Wrapper
{
private final long creationNanoTime = NanoTime.now();
public Cookie(HttpCookie wrapped)
{
super(wrapped);
}
@Override
public boolean isExpired()
{
long maxAge = getMaxAge();
if (maxAge >= 0 && NanoTime.secondsSince(creationNanoTime) > maxAge)
return true;
Instant expires = getExpires();
return expires != null && Instant.now().isAfter(expires);
}
}
}
}

View File

@ -86,4 +86,9 @@ public enum HttpScheme
HttpScheme httpScheme = scheme == null ? null : CACHE.get(scheme);
return httpScheme == null ? port : httpScheme.normalizePort(port);
}
public static boolean isSecure(String scheme)
{
return HttpScheme.HTTPS.is(scheme) || HttpScheme.WSS.is(scheme);
}
}

View File

@ -30,9 +30,9 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.http.PreEncodedHttpField;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Retainable;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.NanoTime;
import org.eclipse.jetty.util.StringUtil;
@ -69,16 +69,16 @@ public class CachingHttpContentFactory implements HttpContent.Factory
private final HttpContent.Factory _authority;
private final ConcurrentHashMap<String, CachingHttpContent> _cache = new ConcurrentHashMap<>();
private final AtomicLong _cachedSize = new AtomicLong();
private final RetainableByteBufferPool _bufferPool;
private final ByteBufferPool _bufferPool;
private int _maxCachedFileSize = DEFAULT_MAX_CACHED_FILE_SIZE;
private int _maxCachedFiles = DEFAULT_MAX_CACHED_FILES;
private long _maxCacheSize = DEFAULT_MAX_CACHE_SIZE;
private boolean _useDirectByteBuffers = true;
public CachingHttpContentFactory(HttpContent.Factory authority, RetainableByteBufferPool bufferPool)
public CachingHttpContentFactory(HttpContent.Factory authority, ByteBufferPool bufferPool)
{
_authority = authority;
_bufferPool = bufferPool != null ? bufferPool : new RetainableByteBufferPool.NonPooling();
_bufferPool = bufferPool != null ? bufferPool : new ByteBufferPool.NonPooling();
}
protected ConcurrentMap<String, CachingHttpContent> getCache()

View File

@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.NanoTime;
import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.thread.Scheduler;
@ -55,11 +55,11 @@ public class ValidatingCachingHttpContentFactory extends CachingHttpContentFacto
*
* @param authority the wrapped {@link HttpContent.Factory} to use.
* @param validationPeriod time between filesystem checks in ms to see if an {@link HttpContent} is still valid (-1 never validate, 0 always validate).
* @param bufferPool the {@link org.eclipse.jetty.io.RetainableByteBufferPool} to use.
* @param bufferPool the {@link org.eclipse.jetty.io.ByteBufferPool} to use.
*/
public ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority,
@Name("validationPeriod") long validationPeriod,
@Name("bufferPool") RetainableByteBufferPool bufferPool)
@Name("bufferPool") ByteBufferPool bufferPool)
{
this(authority, validationPeriod, bufferPool, null, -1, -1);
}
@ -70,14 +70,14 @@ public class ValidatingCachingHttpContentFactory extends CachingHttpContentFacto
*
* @param authority the wrapped {@link HttpContent.Factory} to use.
* @param validationPeriod time between filesystem checks in ms to see if an {@link HttpContent} is still valid (-1 never validate, 0 always validate).
* @param bufferPool the {@link org.eclipse.jetty.io.RetainableByteBufferPool} to use.
* @param bufferPool the {@link org.eclipse.jetty.io.ByteBufferPool} to use.
* @param scheduler scheduler to use for the sweeper, can be null to not use sweeper.
* @param sweepPeriod time between runs of the sweeper in ms (if 0 never sweep for invalid entries).
* @param idleTimeout amount of time in ms an entry can be unused before evicted by the sweeper (if 0 never evict unused entries).
*/
public ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority,
@Name("validationPeriod") long validationPeriod,
@Name("byteBufferPool") RetainableByteBufferPool bufferPool,
@Name("byteBufferPool") ByteBufferPool bufferPool,
@Name("scheduler") Scheduler scheduler,
@Name("sweepPeriod") long sweepPeriod,
@Name("idleTimeout") long idleTimeout)

View File

@ -23,9 +23,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -42,12 +42,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class GZIPContentDecoderTest
{
private final AtomicInteger counter = new AtomicInteger();
private RetainableByteBufferPool pool;
private ByteBufferPool pool;
@BeforeEach
public void before()
{
pool = new RetainableByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool())
pool = new ByteBufferPool.Wrapper(new ArrayByteBufferPool())
{
@Override
public RetainableByteBuffer acquire(int size, boolean direct)

View File

@ -0,0 +1,278 @@
//
// ========================================================================
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.http;
import java.net.URI;
import java.time.Instant;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class HttpCookieStoreTest
{
@Test
public void testRejectCookieForTopDomain()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://example.com");
assertFalse(store.add(uri, HttpCookie.build("n", "v").domain("com").build()));
assertFalse(store.add(uri, HttpCookie.build("n", "v").domain(".com").build()));
}
@Test
public void testRejectExpiredCookie()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://example.com");
assertFalse(store.add(uri, HttpCookie.build("n", "v").maxAge(0).build()));
assertFalse(store.add(uri, HttpCookie.build("n", "v").expires(Instant.now().minusSeconds(1)).build()));
}
@Test
public void testRejectCookieForNonMatchingDomain()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://example.com");
assertFalse(store.add(uri, HttpCookie.build("n", "v").domain("sub.example.com").build()));
assertFalse(store.add(uri, HttpCookie.build("n", "v").domain("foo.com").build()));
}
@Test
public void testAcceptCookieForMatchingDomain()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://sub.example.com");
assertTrue(store.add(uri, HttpCookie.build("n", "v").domain("sub.example.com").build()));
assertTrue(store.add(uri, HttpCookie.build("n", "v").domain("example.com").build()));
}
@Test
public void testAcceptCookieForLocalhost()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://localhost");
assertTrue(store.add(uri, HttpCookie.build("n", "v").domain("localhost").build()));
}
@Test
public void testReplaceCookie()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://example.com");
assertTrue(store.add(uri, HttpCookie.from("n", "v1")));
// Replace the cookie with another that has a different value.
assertTrue(store.add(uri, HttpCookie.from("n", "v2")));
List<HttpCookie> matches = store.match(uri);
assertEquals(1, matches.size());
assertEquals("v2", matches.get(0).getValue());
}
@Test
public void testReplaceCookieWithDomain()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://example.com");
assertTrue(store.add(uri, HttpCookie.build("n", "v1").domain("example.com").build()));
// Replace the cookie with another that has a different value.
// Domain comparison must be case-insensitive.
assertTrue(store.add(uri, HttpCookie.build("n", "v2").domain("EXAMPLE.COM").build()));
List<HttpCookie> matches = store.match(uri);
assertEquals(1, matches.size());
assertEquals("v2", matches.get(0).getValue());
}
@Test
public void testReplaceCookieWithPath()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://example.com/path");
assertTrue(store.add(uri, HttpCookie.build("n", "v1").path("/path").build()));
// Replace the cookie with another that has a different value.
// Path comparison must be case-sensitive.
assertTrue(store.add(uri, HttpCookie.build("n", "v2").path("/path").build()));
List<HttpCookie> matches = store.match(uri);
assertEquals(1, matches.size());
assertEquals("v2", matches.get(0).getValue());
// Same path but different case should generate another cookie.
assertTrue(store.add(uri, HttpCookie.build("n", "v3").path("/PATH").build()));
matches = store.all();
assertEquals(2, matches.size());
}
@Test
public void testMatch()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI cookieURI = URI.create("http://example.com");
assertTrue(store.add(cookieURI, HttpCookie.from("n", "v1")));
// Same domain with a path must match.
URI uri = URI.create("http://example.com/path");
List<HttpCookie> matches = store.match(uri);
assertEquals(1, matches.size());
// Subdomain must not match because the cookie was added without
// Domain attribute, so must be sent only to the origin domain.
uri = URI.create("http://sub.example.com");
matches = store.match(uri);
assertEquals(0, matches.size());
// Different domain must not match.
uri = URI.create("http://foo.com");
matches = store.match(uri);
assertEquals(0, matches.size());
}
@Test
public void testMatchWithDomain()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI cookieURI = URI.create("http://sub.example.com");
assertTrue(store.add(cookieURI, HttpCookie.build("n", "v1").domain("example.com").build()));
// Same domain with a path must match.
URI uri = URI.create("http://sub.example.com/path");
List<HttpCookie> matches = store.match(uri);
assertEquals(1, matches.size());
// Parent domain must match.
uri = URI.create("http://example.com");
matches = store.match(uri);
assertEquals(1, matches.size());
// Different subdomain must match due to the Domain attribute.
uri = URI.create("http://bar.example.com");
matches = store.match(uri);
assertEquals(1, matches.size());
}
@Test
public void testMatchManyWithDomain()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI cookieURI = URI.create("http://sub.example.com");
assertTrue(store.add(cookieURI, HttpCookie.build("n1", "v1").domain("example.com").build()));
cookieURI = URI.create("http://example.com");
assertTrue(store.add(cookieURI, HttpCookie.from("n2", "v2")));
URI uri = URI.create("http://sub.example.com/path");
List<HttpCookie> matches = store.match(uri);
assertEquals(1, matches.size());
// Parent domain must match.
uri = URI.create("http://example.com");
matches = store.match(uri);
assertEquals(2, matches.size());
// Different subdomain must match due to the Domain attribute.
uri = URI.create("http://bar.example.com");
matches = store.match(uri);
assertEquals(1, matches.size());
}
@Test
public void testMatchManyWithPath()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI cookieURI = URI.create("http://example.com");
assertTrue(store.add(cookieURI, HttpCookie.build("n1", "v1").path("/path").build()));
cookieURI = URI.create("http://example.com");
assertTrue(store.add(cookieURI, HttpCookie.from("n2", "v2")));
URI uri = URI.create("http://example.com");
List<HttpCookie> matches = store.match(uri);
assertEquals(1, matches.size());
uri = URI.create("http://example.com/");
matches = store.match(uri);
assertEquals(1, matches.size());
uri = URI.create("http://example.com/other");
matches = store.match(uri);
assertEquals(1, matches.size());
uri = URI.create("http://example.com/path");
matches = store.match(uri);
assertEquals(2, matches.size());
uri = URI.create("http://example.com/path/");
matches = store.match(uri);
assertEquals(2, matches.size());
uri = URI.create("http://example.com/path/more");
matches = store.match(uri);
assertEquals(2, matches.size());
}
@Test
public void testExpiredCookieDoesNotMatch() throws Exception
{
HttpCookieStore store = new HttpCookieStore.Default();
URI cookieURI = URI.create("http://example.com");
long expireSeconds = 1;
assertTrue(store.add(cookieURI, HttpCookie.build("n1", "v1").maxAge(expireSeconds).build()));
TimeUnit.SECONDS.sleep(2 * expireSeconds);
List<HttpCookie> matches = store.match(cookieURI);
assertEquals(0, matches.size());
}
@Test
public void testRemove()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI cookieURI = URI.create("http://example.com/path");
assertTrue(store.add(cookieURI, HttpCookie.from("n1", "v1")));
URI removeURI = URI.create("http://example.com");
// Cookie value should not matter.
assertTrue(store.remove(removeURI, HttpCookie.from("n1", "n2")));
assertFalse(store.remove(removeURI, HttpCookie.from("n1", "n2")));
}
@Test
public void testSecureCookie()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI uri = URI.create("http://example.com");
// Dumb server sending a secure cookie on clear-text scheme.
assertFalse(store.add(uri, HttpCookie.build("n1", "v1").secure(true).build()));
URI secureURI = URI.create("https://example.com");
assertTrue(store.add(secureURI, HttpCookie.build("n2", "v2").secure(true).build()));
assertTrue(store.add(secureURI, HttpCookie.from("n3", "v3")));
List<HttpCookie> matches = store.match(uri);
assertEquals(0, matches.size());
matches = store.match(secureURI);
assertEquals(2, matches.size());
}
@Test
public void testClear()
{
HttpCookieStore store = new HttpCookieStore.Default();
URI cookieURI = URI.create("http://example.com");
assertTrue(store.add(cookieURI, HttpCookie.from("n1", "v1")));
assertTrue(store.clear());
assertFalse(store.clear());
}
}

View File

@ -90,7 +90,7 @@ public class HttpClientTransportOverHTTP2 extends AbstractHttpClientTransport
HttpClient httpClient = getHttpClient();
client.setExecutor(httpClient.getExecutor());
client.setScheduler(httpClient.getScheduler());
client.setRetainableByteBufferPool(httpClient.getRetainableByteBufferPool());
client.setByteBufferPool(httpClient.getByteBufferPool());
client.setConnectTimeout(httpClient.getConnectTimeout());
client.setIdleTimeout(httpClient.getIdleTimeout());
client.setInputBufferSize(httpClient.getResponseBufferSize());

View File

@ -28,9 +28,9 @@ import org.eclipse.jetty.http2.FlowControlStrategy;
import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
@ -153,14 +153,14 @@ public class HTTP2Client extends ContainerLifeCycle
connector.setScheduler(scheduler);
}
public RetainableByteBufferPool getRetainableByteBufferPool()
public ByteBufferPool getByteBufferPool()
{
return connector.getRetainableByteBufferPool();
return connector.getByteBufferPool();
}
public void setRetainableByteBufferPool(RetainableByteBufferPool bufferPool)
public void setByteBufferPool(ByteBufferPool bufferPool)
{
connector.setRetainableByteBufferPool(bufferPool);
connector.setByteBufferPool(bufferPool);
}
public FlowControlStrategy.Factory getFlowControlStrategyFactory()
@ -435,7 +435,7 @@ public class HTTP2Client extends ContainerLifeCycle
{
if (isUseALPN())
factory = new ALPNClientConnectionFactory(getExecutor(), factory, getProtocols());
factory = new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), factory);
factory = new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), factory);
}
return factory;
}

View File

@ -28,10 +28,10 @@ import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.thread.Scheduler;
@ -48,7 +48,7 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
public Connection newConnection(EndPoint endPoint, Map<String, Object> context)
{
HTTP2Client client = (HTTP2Client)context.get(CLIENT_CONTEXT_KEY);
RetainableByteBufferPool bufferPool = client.getRetainableByteBufferPool();
ByteBufferPool bufferPool = client.getByteBufferPool();
Executor executor = client.getExecutor();
Scheduler scheduler = client.getScheduler();
Session.Listener listener = (Session.Listener)context.get(SESSION_LISTENER_CONTEXT_KEY);
@ -81,9 +81,9 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
private final Promise<Session> promise;
private final Session.Listener listener;
private HTTP2ClientConnection(HTTP2Client client, RetainableByteBufferPool retainableByteBufferPool, Executor executor, EndPoint endpoint, Parser parser, HTTP2Session session, int bufferSize, Promise<Session> promise, Session.Listener listener)
private HTTP2ClientConnection(HTTP2Client client, ByteBufferPool byteBufferPool, Executor executor, EndPoint endpoint, Parser parser, HTTP2Session session, int bufferSize, Promise<Session> promise, Session.Listener listener)
{
super(retainableByteBufferPool, executor, endpoint, parser, session, bufferSize);
super(byteBufferPool, executor, endpoint, parser, session, bufferSize);
this.client = client;
this.promise = promise;
this.listener = listener;

View File

@ -24,11 +24,11 @@ import org.eclipse.jetty.http2.api.Stream;
import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.Retainable;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.WriteFlusher;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
@ -47,7 +47,7 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
private final Queue<Runnable> tasks = new ArrayDeque<>();
private final HTTP2Producer producer = new HTTP2Producer();
private final AtomicLong bytesIn = new AtomicLong();
private final RetainableByteBufferPool retainableByteBufferPool;
private final ByteBufferPool byteBufferPool;
private final Parser parser;
private final HTTP2Session session;
private final int bufferSize;
@ -55,10 +55,10 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
private boolean useInputDirectByteBuffers;
private boolean useOutputDirectByteBuffers;
protected HTTP2Connection(RetainableByteBufferPool retainableByteBufferPool, Executor executor, EndPoint endPoint, Parser parser, HTTP2Session session, int bufferSize)
protected HTTP2Connection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, Parser parser, HTTP2Session session, int bufferSize)
{
super(endPoint, executor);
this.retainableByteBufferPool = retainableByteBufferPool;
this.byteBufferPool = byteBufferPool;
this.parser = parser;
this.session = session;
this.bufferSize = bufferSize;
@ -450,7 +450,7 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
private NetworkBuffer()
{
delegate = retainableByteBufferPool.acquire(bufferSize, isUseInputDirectByteBuffers());
delegate = byteBufferPool.acquire(bufferSize, isUseInputDirectByteBuffers());
}
public ByteBuffer getBuffer()

View File

@ -56,9 +56,9 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.internal.HTTP2Flusher;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.CyclicTimeouts;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.WriteFlusher;
import org.eclipse.jetty.util.AtomicBiInteger;
import org.eclipse.jetty.util.Atomics;
@ -1208,7 +1208,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements Session
return 0;
}
public abstract boolean generate(RetainableByteBufferPool.Accumulator accumulator) throws HpackException;
public abstract boolean generate(ByteBufferPool.Accumulator accumulator) throws HpackException;
public abstract long onFlushed(long bytes) throws IOException;
@ -1295,7 +1295,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements Session
}
@Override
public boolean generate(RetainableByteBufferPool.Accumulator accumulator) throws HpackException
public boolean generate(ByteBufferPool.Accumulator accumulator) throws HpackException
{
frameBytes = generator.control(accumulator, frame);
beforeSend();
@ -1409,7 +1409,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements Session
}
@Override
public boolean generate(RetainableByteBufferPool.Accumulator accumulator)
public boolean generate(ByteBufferPool.Accumulator accumulator)
{
int dataRemaining = getDataBytesRemaining();

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class DataGenerator
@ -32,12 +32,12 @@ public class DataGenerator
this.headerGenerator = headerGenerator;
}
public int generate(RetainableByteBufferPool.Accumulator accumulator, DataFrame frame, int maxLength)
public int generate(ByteBufferPool.Accumulator accumulator, DataFrame frame, int maxLength)
{
return generateData(accumulator, frame.getStreamId(), frame.getByteBuffer(), frame.isEndStream(), maxLength);
}
public int generateData(RetainableByteBufferPool.Accumulator accumulator, int streamId, ByteBuffer data, boolean last, int maxLength)
public int generateData(ByteBufferPool.Accumulator accumulator, int streamId, ByteBuffer data, boolean last, int maxLength)
{
if (streamId < 0)
throw new IllegalArgumentException("Invalid stream id: " + streamId);
@ -62,7 +62,7 @@ public class DataGenerator
return Frame.HEADER_LENGTH + length;
}
private void generateFrame(RetainableByteBufferPool.Accumulator accumulator, int streamId, ByteBuffer data, boolean last)
private void generateFrame(ByteBufferPool.Accumulator accumulator, int streamId, ByteBuffer data, boolean last)
{
int length = data.remaining();

View File

@ -20,8 +20,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public abstract class FrameGenerator
@ -33,7 +33,7 @@ public abstract class FrameGenerator
this.headerGenerator = headerGenerator;
}
public abstract int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException;
public abstract int generate(ByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException;
protected RetainableByteBuffer generateHeader(FrameType frameType, int length, int flags, int streamId)
{
@ -52,7 +52,7 @@ public abstract class FrameGenerator
protected RetainableByteBuffer encode(HpackEncoder encoder, MetaData metaData, int maxFrameSize) throws HpackException
{
RetainableByteBuffer hpacked = headerGenerator.getRetainableByteBufferPool().acquire(maxFrameSize, isUseDirectByteBuffers());
RetainableByteBuffer hpacked = headerGenerator.getByteBufferPool().acquire(maxFrameSize, isUseDirectByteBuffers());
try
{
ByteBuffer byteBuffer = hpacked.getByteBuffer();

View File

@ -18,27 +18,27 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
public class Generator
{
private final RetainableByteBufferPool bufferPool;
private final ByteBufferPool bufferPool;
private final HeaderGenerator headerGenerator;
private final HpackEncoder hpackEncoder;
private final FrameGenerator[] generators;
private final DataGenerator dataGenerator;
public Generator(RetainableByteBufferPool bufferPool)
public Generator(ByteBufferPool bufferPool)
{
this(bufferPool, 4096, 0);
}
public Generator(RetainableByteBufferPool bufferPool, int maxDynamicTableSize, int maxHeaderBlockFragment)
public Generator(ByteBufferPool bufferPool, int maxDynamicTableSize, int maxHeaderBlockFragment)
{
this(bufferPool, true, maxDynamicTableSize, maxHeaderBlockFragment);
}
public Generator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers, int maxDynamicTableSize, int maxHeaderBlockFragment)
public Generator(ByteBufferPool bufferPool, boolean useDirectByteBuffers, int maxDynamicTableSize, int maxHeaderBlockFragment)
{
this.bufferPool = bufferPool;
@ -61,7 +61,7 @@ public class Generator
this.dataGenerator = new DataGenerator(headerGenerator);
}
public RetainableByteBufferPool getRetainableByteBufferPool()
public ByteBufferPool getByteBufferPool()
{
return bufferPool;
}
@ -81,12 +81,12 @@ public class Generator
headerGenerator.setMaxFrameSize(maxFrameSize);
}
public int control(RetainableByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
public int control(ByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
{
return generators[frame.getType().getType()].generate(accumulator, frame);
}
public int data(RetainableByteBufferPool.Accumulator accumulator, DataFrame frame, int maxLength)
public int data(ByteBufferPool.Accumulator accumulator, DataFrame frame, int maxLength)
{
return dataGenerator.generate(accumulator, frame, maxLength);
}

View File

@ -20,8 +20,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.GoAwayFrame;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class GoAwayGenerator extends FrameGenerator
@ -32,13 +32,13 @@ public class GoAwayGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame)
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{
GoAwayFrame goAwayFrame = (GoAwayFrame)frame;
return generateGoAway(accumulator, goAwayFrame.getLastStreamId(), goAwayFrame.getError(), goAwayFrame.getPayload());
}
public int generateGoAway(RetainableByteBufferPool.Accumulator accumulator, int lastStreamId, int error, byte[] payload)
public int generateGoAway(ByteBufferPool.Accumulator accumulator, int lastStreamId, int error, byte[] payload)
{
if (lastStreamId < 0)
lastStreamId = 0;

View File

@ -17,28 +17,28 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class HeaderGenerator
{
private int maxFrameSize = Frame.DEFAULT_MAX_LENGTH;
private final RetainableByteBufferPool bufferPool;
private final ByteBufferPool bufferPool;
private final boolean useDirectByteBuffers;
public HeaderGenerator(RetainableByteBufferPool bufferPool)
public HeaderGenerator(ByteBufferPool bufferPool)
{
this(bufferPool, true);
}
public HeaderGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers)
public HeaderGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{
this.bufferPool = bufferPool;
this.useDirectByteBuffers = useDirectByteBuffers;
}
public RetainableByteBufferPool getRetainableByteBufferPool()
public ByteBufferPool getByteBufferPool()
{
return bufferPool;
}
@ -50,7 +50,7 @@ public class HeaderGenerator
public RetainableByteBuffer generate(FrameType frameType, int capacity, int length, int flags, int streamId)
{
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(capacity, isUseDirectByteBuffers());
RetainableByteBuffer buffer = getByteBufferPool().acquire(capacity, isUseDirectByteBuffers());
ByteBuffer header = buffer.getByteBuffer();
BufferUtil.clearToFill(header);
header.put((byte)((length & 0x00_FF_00_00) >>> 16));

View File

@ -23,8 +23,8 @@ import org.eclipse.jetty.http2.frames.PriorityFrame;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class HeadersGenerator extends FrameGenerator
@ -47,13 +47,13 @@ public class HeadersGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
{
HeadersFrame headersFrame = (HeadersFrame)frame;
return generateHeaders(accumulator, headersFrame.getStreamId(), headersFrame.getMetaData(), headersFrame.getPriority(), headersFrame.isEndStream());
}
public int generateHeaders(RetainableByteBufferPool.Accumulator accumulator, int streamId, MetaData metaData, PriorityFrame priority, boolean endStream) throws HpackException
public int generateHeaders(ByteBufferPool.Accumulator accumulator, int streamId, MetaData metaData, PriorityFrame priority, boolean endStream) throws HpackException
{
if (streamId < 0)
throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -14,7 +14,7 @@
package org.eclipse.jetty.http2.generator;
import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
public class NoOpGenerator extends FrameGenerator
{
@ -24,7 +24,7 @@ public class NoOpGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame)
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{
return 0;
}

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.PingFrame;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class PingGenerator extends FrameGenerator
@ -31,13 +31,13 @@ public class PingGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame)
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{
PingFrame pingFrame = (PingFrame)frame;
return generatePing(accumulator, pingFrame.getPayload(), pingFrame.isReply());
}
public int generatePing(RetainableByteBufferPool.Accumulator accumulator, byte[] payload, boolean reply)
public int generatePing(ByteBufferPool.Accumulator accumulator, byte[] payload, boolean reply)
{
if (payload.length != PingFrame.PING_LENGTH)
throw new IllegalArgumentException("Invalid payload length: " + payload.length);

View File

@ -17,8 +17,8 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
public class PrefaceGenerator extends FrameGenerator
{
@ -28,7 +28,7 @@ public class PrefaceGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame)
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{
accumulator.append(RetainableByteBuffer.wrap(ByteBuffer.wrap(PrefaceFrame.PREFACE_BYTES)));
return PrefaceFrame.PREFACE_BYTES.length;

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.PriorityFrame;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class PriorityGenerator extends FrameGenerator
@ -31,13 +31,13 @@ public class PriorityGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame)
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{
PriorityFrame priorityFrame = (PriorityFrame)frame;
return generatePriority(accumulator, priorityFrame.getStreamId(), priorityFrame.getParentStreamId(), priorityFrame.getWeight(), priorityFrame.isExclusive());
}
public int generatePriority(RetainableByteBufferPool.Accumulator accumulator, int streamId, int parentStreamId, int weight, boolean exclusive)
public int generatePriority(ByteBufferPool.Accumulator accumulator, int streamId, int parentStreamId, int weight, boolean exclusive)
{
RetainableByteBuffer header = generateHeader(FrameType.PRIORITY, PriorityFrame.PRIORITY_LENGTH, Flags.NONE, streamId);
ByteBuffer byteBuffer = header.getByteBuffer();

View File

@ -22,8 +22,8 @@ import org.eclipse.jetty.http2.frames.PushPromiseFrame;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class PushPromiseGenerator extends FrameGenerator
@ -37,13 +37,13 @@ public class PushPromiseGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
{
PushPromiseFrame pushPromiseFrame = (PushPromiseFrame)frame;
return generatePushPromise(accumulator, pushPromiseFrame.getStreamId(), pushPromiseFrame.getPromisedStreamId(), pushPromiseFrame.getMetaData());
}
public int generatePushPromise(RetainableByteBufferPool.Accumulator accumulator, int streamId, int promisedStreamId, MetaData metaData) throws HpackException
public int generatePushPromise(ByteBufferPool.Accumulator accumulator, int streamId, int promisedStreamId, MetaData metaData) throws HpackException
{
if (streamId < 0)
throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.ResetFrame;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class ResetGenerator extends FrameGenerator
@ -31,13 +31,13 @@ public class ResetGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame)
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{
ResetFrame resetFrame = (ResetFrame)frame;
return generateReset(accumulator, resetFrame.getStreamId(), resetFrame.getError());
}
public int generateReset(RetainableByteBufferPool.Accumulator accumulator, int streamId, int error)
public int generateReset(ByteBufferPool.Accumulator accumulator, int streamId, int error)
{
if (streamId < 0)
throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -20,8 +20,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class SettingsGenerator extends FrameGenerator
@ -32,13 +32,13 @@ public class SettingsGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame)
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{
SettingsFrame settingsFrame = (SettingsFrame)frame;
return generateSettings(accumulator, settingsFrame.getSettings(), settingsFrame.isReply());
}
public int generateSettings(RetainableByteBufferPool.Accumulator accumulator, Map<Integer, Integer> settings, boolean reply)
public int generateSettings(ByteBufferPool.Accumulator accumulator, Map<Integer, Integer> settings, boolean reply)
{
// Two bytes for the identifier, four bytes for the value.
int entryLength = 2 + 4;

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class WindowUpdateGenerator extends FrameGenerator
@ -31,13 +31,13 @@ public class WindowUpdateGenerator extends FrameGenerator
}
@Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame)
public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{
WindowUpdateFrame windowUpdateFrame = (WindowUpdateFrame)frame;
return generateWindowUpdate(accumulator, windowUpdateFrame.getStreamId(), windowUpdateFrame.getWindowDelta());
}
public int generateWindowUpdate(RetainableByteBufferPool.Accumulator accumulator, int streamId, int windowUpdate)
public int generateWindowUpdate(ByteBufferPool.Accumulator accumulator, int streamId, int windowUpdate)
{
if (windowUpdate < 0)
throw new IllegalArgumentException("Invalid window update: " + windowUpdate);

View File

@ -30,8 +30,8 @@ import org.eclipse.jetty.http2.HTTP2Session;
import org.eclipse.jetty.http2.HTTP2Stream;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.IteratingCallback;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.thread.AutoLock;
@ -50,7 +50,7 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable
private final Queue<HTTP2Session.Entry> pendingEntries = new ArrayDeque<>();
private final Collection<HTTP2Session.Entry> processedEntries = new ArrayList<>();
private final HTTP2Session session;
private final RetainableByteBufferPool.Accumulator accumulator;
private final ByteBufferPool.Accumulator accumulator;
private InvocationType invocationType = InvocationType.NON_BLOCKING;
private Throwable terminated;
private HTTP2Session.Entry stalledEntry;
@ -58,7 +58,7 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable
public HTTP2Flusher(HTTP2Session session)
{
this.session = session;
this.accumulator = new RetainableByteBufferPool.Accumulator();
this.accumulator = new ByteBufferPool.Accumulator();
}
@Override

View File

@ -16,19 +16,19 @@ package org.eclipse.jetty.http2.parser;
import java.nio.ByteBuffer;
import org.eclipse.jetty.http2.frames.PriorityFrame;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
public class HeaderBlockFragments
{
private final RetainableByteBufferPool bufferPool;
private final ByteBufferPool bufferPool;
private PriorityFrame priorityFrame;
private boolean endStream;
private int streamId;
private RetainableByteBuffer storage;
public HeaderBlockFragments(RetainableByteBufferPool bufferPool)
public HeaderBlockFragments(ByteBufferPool bufferPool)
{
this.bufferPool = bufferPool;
}

View File

@ -20,8 +20,8 @@ import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.hpack.HpackDecoder;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -33,12 +33,12 @@ public class HeaderBlockParser
private static final Logger LOG = LoggerFactory.getLogger(HeaderBlockParser.class);
private final HeaderParser headerParser;
private final RetainableByteBufferPool bufferPool;
private final ByteBufferPool bufferPool;
private final HpackDecoder hpackDecoder;
private final BodyParser notifier;
private RetainableByteBuffer blockBuffer;
public HeaderBlockParser(HeaderParser headerParser, RetainableByteBufferPool bufferPool, HpackDecoder hpackDecoder, BodyParser notifier)
public HeaderBlockParser(HeaderParser headerParser, ByteBufferPool bufferPool, HpackDecoder hpackDecoder, BodyParser notifier)
{
this.headerParser = headerParser;
this.bufferPool = bufferPool;

View File

@ -31,7 +31,7 @@ import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.hpack.HpackDecoder;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -44,7 +44,7 @@ public class Parser
{
private static final Logger LOG = LoggerFactory.getLogger(Parser.class);
private final RetainableByteBufferPool bufferPool;
private final ByteBufferPool bufferPool;
private final Listener listener;
private final HeaderParser headerParser;
private final HpackDecoder hpackDecoder;
@ -55,12 +55,12 @@ public class Parser
private boolean continuation;
private State state = State.HEADER;
public Parser(RetainableByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize)
public Parser(ByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize)
{
this(bufferPool, listener, maxDynamicTableSize, maxHeaderSize, RateControl.NO_RATE_CONTROL);
}
public Parser(RetainableByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize, RateControl rateControl)
public Parser(ByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize, RateControl rateControl)
{
this.bufferPool = bufferPool;
this.listener = listener;

View File

@ -19,7 +19,7 @@ import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.RateControl;
import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -33,7 +33,7 @@ public class ServerParser extends Parser
private State state = State.PREFACE;
private boolean notifyPreface = true;
public ServerParser(RetainableByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize, RateControl rateControl)
public ServerParser(ByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize, RateControl rateControl)
{
super(bufferPool, listener, maxDynamicTableSize, maxHeaderSize, rateControl);
this.listener = listener;

View File

@ -29,8 +29,8 @@ import org.eclipse.jetty.http2.generator.HeadersGenerator;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -42,7 +42,7 @@ public class ContinuationParseTest
@Test
public void testParseOneByteAtATime() throws Exception
{
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
HeadersGenerator generator = new HeadersGenerator(new HeaderGenerator(bufferPool), new HpackEncoder());
final List<HeadersFrame> frames = new ArrayList<>();
@ -71,7 +71,7 @@ public class ContinuationParseTest
.put("User-Agent", "Jetty");
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields, -1);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateHeaders(accumulator, streamId, metaData, null, true);
List<ByteBuffer> byteBuffers = accumulator.getByteBuffers();

View File

@ -22,8 +22,8 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.generator.DataGenerator;
import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.junit.jupiter.api.Test;
@ -34,7 +34,7 @@ public class DataGenerateParseTest
{
private final byte[] smallContent = new byte[128];
private final byte[] largeContent = new byte[128 * 1024];
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
public DataGenerateParseTest()
{
@ -101,7 +101,7 @@ public class DataGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
ByteBuffer slice = data.slice();
int generated = 0;
while (true)
@ -141,7 +141,7 @@ public class DataGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
ByteBuffer data = ByteBuffer.wrap(largeContent);
ByteBuffer slice = data.slice();
int generated = 0;

View File

@ -24,8 +24,8 @@ import org.eclipse.jetty.http2.WindowRateControl;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.lessThan;
public class FrameFloodTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
// Frame structure:
// | Len0 | Len1 | Len2 | Type | Flags | StreamID0 |StreamID1 |StreamID2 |StreamID3 | Payload... |

View File

@ -22,8 +22,8 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.generator.GoAwayGenerator;
import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
public class GoAwayGenerateParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testGenerateParse() throws Exception
@ -56,7 +56,7 @@ public class GoAwayGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateGoAway(accumulator, lastStreamId, error, null);
frames.clear();
@ -100,7 +100,7 @@ public class GoAwayGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateGoAway(accumulator, lastStreamId, error, payload);
frames.clear();

View File

@ -28,8 +28,8 @@ import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.HeadersGenerator;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class HeadersGenerateParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testGenerateParse() throws Exception
@ -65,7 +65,7 @@ public class HeadersGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true);
generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true);
@ -124,7 +124,7 @@ public class HeadersGenerateParseTest
.put("User-Agent", "Jetty");
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields, -1);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true);
generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true);

View File

@ -28,8 +28,8 @@ import org.eclipse.jetty.http2.generator.HeadersGenerator;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class HeadersTooLargeParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testProtocolErrorURITooLong() throws HpackException
@ -78,7 +78,7 @@ public class HeadersTooLargeParseTest
parser.init(UnaryOperator.identity());
int streamId = 48;
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true);
int len = generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true);

View File

@ -19,15 +19,15 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class MaxFrameSizeParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testMaxFrameSize()

View File

@ -22,8 +22,8 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.PingGenerator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.NanoTime;
import org.junit.jupiter.api.Test;
@ -33,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class PingGenerateParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testGenerateParse() throws Exception
@ -57,7 +57,7 @@ public class PingGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePing(accumulator, payload, true);
frames.clear();
@ -98,7 +98,7 @@ public class PingGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePing(accumulator, payload, true);
frames.clear();
@ -133,7 +133,7 @@ public class PingGenerateParseTest
}, 4096, 8192);
parser.init(UnaryOperator.identity());
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
PingFrame ping = new PingFrame(NanoTime.now(), true);
generator.generate(accumulator, ping);

View File

@ -21,15 +21,15 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.PriorityGenerator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class PriorityGenerateParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testGenerateParse() throws Exception
@ -55,7 +55,7 @@ public class PriorityGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePriority(accumulator, streamId, parentStreamId, weight, exclusive);
frames.clear();
@ -100,7 +100,7 @@ public class PriorityGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePriority(accumulator, streamId, parentStreamId, weight, exclusive);
frames.clear();

View File

@ -28,8 +28,8 @@ import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.PushPromiseGenerator;
import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class PushPromiseGenerateParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testGenerateParse() throws Exception
@ -65,7 +65,7 @@ public class PushPromiseGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePushPromise(accumulator, streamId, promisedStreamId, metaData);
frames.clear();
@ -118,7 +118,7 @@ public class PushPromiseGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePushPromise(accumulator, streamId, promisedStreamId, metaData);
frames.clear();

View File

@ -21,15 +21,15 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.ResetGenerator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ResetGenerateParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testGenerateParse() throws Exception
@ -53,7 +53,7 @@ public class ResetGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateReset(accumulator, streamId, error);
frames.clear();
@ -94,7 +94,7 @@ public class ResetGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateReset(accumulator, streamId, error);
frames.clear();

View File

@ -26,8 +26,8 @@ import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.SettingsGenerator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class SettingsGenerateParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testGenerateParseNoSettings()
@ -85,7 +85,7 @@ public class SettingsGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateSettings(accumulator, settings, true);
frames.clear();
@ -119,7 +119,7 @@ public class SettingsGenerateParseTest
Map<Integer, Integer> settings1 = new HashMap<>();
settings1.put(13, 17);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateSettings(accumulator, settings1, true);
// Modify the length of the frame to make it invalid
ByteBuffer bytes = accumulator.getByteBuffers().get(0);
@ -160,7 +160,7 @@ public class SettingsGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateSettings(accumulator, settings1, true);
frames.clear();
@ -205,7 +205,7 @@ public class SettingsGenerateParseTest
settings.put(i + 10, i);
}
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateSettings(accumulator, settings, false);
for (ByteBuffer buffer : accumulator.getByteBuffers())
@ -283,7 +283,7 @@ public class SettingsGenerateParseTest
Map<Integer, Integer> settings = new HashMap<>();
settings.put(13, 17);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
for (int i = 0; i < maxSettingsKeys + 1; ++i)
{
generator.generateSettings(accumulator, settings, false);

View File

@ -21,8 +21,8 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
public class UnknownParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testParse()

View File

@ -21,15 +21,15 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.WindowUpdateGenerator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class WindowUpdateGenerateParseTest
{
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
private final ByteBufferPool bufferPool = new ArrayByteBufferPool();
@Test
public void testGenerateParse() throws Exception
@ -53,7 +53,7 @@ public class WindowUpdateGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateWindowUpdate(accumulator, streamId, windowUpdate);
frames.clear();
@ -94,7 +94,7 @@ public class WindowUpdateGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i)
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateWindowUpdate(accumulator, streamId, windowUpdate);
frames.clear();

View File

@ -37,9 +37,9 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.ServerParser;
import org.eclipse.jetty.http2.server.internal.HTTP2ServerConnection;
import org.eclipse.jetty.http2.server.internal.HTTP2ServerSession;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.AbstractConnectionFactory;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
@ -271,7 +271,7 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
{
ServerSessionListener listener = newSessionListener(connector, endPoint);
Generator generator = new Generator(connector.getRetainableByteBufferPool(), isUseOutputDirectByteBuffers(), getMaxDynamicTableSize(), getMaxHeaderBlockFragment());
Generator generator = new Generator(connector.getByteBufferPool(), isUseOutputDirectByteBuffers(), getMaxDynamicTableSize(), getMaxHeaderBlockFragment());
FlowControlStrategy flowControl = getFlowControlStrategyFactory().newFlowControlStrategy();
HTTP2ServerSession session = new HTTP2ServerSession(connector.getScheduler(), endPoint, generator, listener, flowControl);
session.setMaxLocalStreams(getMaxConcurrentStreams());
@ -291,9 +291,9 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
parser.setMaxFrameLength(getMaxFrameLength());
parser.setMaxSettingsKeys(getMaxSettingsKeys());
RetainableByteBufferPool retainableByteBufferPool = connector.getRetainableByteBufferPool();
ByteBufferPool byteBufferPool = connector.getByteBufferPool();
HTTP2Connection connection = new HTTP2ServerConnection(retainableByteBufferPool, connector,
HTTP2Connection connection = new HTTP2ServerConnection(byteBufferPool, connector,
endPoint, httpConfiguration, parser, session, getInputBufferSize(), listener);
connection.setUseInputDirectByteBuffers(isUseInputDirectByteBuffers());
connection.setUseOutputDirectByteBuffers(isUseOutputDirectByteBuffers());
@ -305,7 +305,7 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
private ServerParser newServerParser(Connector connector, ServerParser.Listener listener, RateControl rateControl)
{
return new ServerParser(connector.getRetainableByteBufferPool(), listener, getMaxDynamicTableSize(), getHttpConfiguration().getRequestHeaderSize(), rateControl);
return new ServerParser(connector.getByteBufferPool(), listener, getMaxDynamicTableSize(), getHttpConfiguration().getRequestHeaderSize(), rateControl);
}
@ManagedObject("The container of HTTP/2 sessions")

View File

@ -40,9 +40,9 @@ import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.parser.ServerParser;
import org.eclipse.jetty.http2.parser.SettingsBodyParser;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.server.ConnectionMetaData;
import org.eclipse.jetty.server.Connector;
@ -69,9 +69,9 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
private final HttpConfiguration httpConfig;
private final String id;
public HTTP2ServerConnection(RetainableByteBufferPool retainableByteBufferPool, Connector connector, EndPoint endPoint, HttpConfiguration httpConfig, ServerParser parser, HTTP2Session session, int inputBufferSize, ServerSessionListener listener)
public HTTP2ServerConnection(ByteBufferPool byteBufferPool, Connector connector, EndPoint endPoint, HttpConfiguration httpConfig, ServerParser parser, HTTP2Session session, int inputBufferSize, ServerSessionListener listener)
{
super(retainableByteBufferPool, connector.getExecutor(), endPoint, parser, session, inputBufferSize);
super(byteBufferPool, connector.getExecutor(), endPoint, parser, session, inputBufferSize);
this.connector = connector;
this.listener = listener;
this.httpConfig = httpConfig;

View File

@ -29,8 +29,8 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
@ -42,7 +42,7 @@ import org.junit.jupiter.api.AfterEach;
public class AbstractServerTest
{
protected ServerConnector connector;
protected RetainableByteBufferPool bufferPool;
protected ByteBufferPool bufferPool;
protected Generator generator;
protected Server server;
protected String path;
@ -68,7 +68,7 @@ public class AbstractServerTest
connector = new ServerConnector(server, connectionFactory);
server.addConnector(connector);
path = "/test";
bufferPool = new ArrayRetainableByteBufferPool();
bufferPool = new ArrayByteBufferPool();
generator = new Generator(bufferPool);
}

View File

@ -31,7 +31,7 @@ import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Request;
@ -97,7 +97,7 @@ public class BadURITest
}
});
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool();
ByteBufferPool bufferPool = connector.getByteBufferPool();
Generator generator = new Generator(bufferPool);
// Craft a request with a bad URI, it will not hit the Handler.
@ -111,7 +111,7 @@ public class BadURITest
HttpFields.EMPTY,
-1
);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
generator.control(accumulator, new HeadersFrame(1, metaData1, null, true));

View File

@ -37,7 +37,7 @@ import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
@ -74,7 +74,7 @@ public class CloseTest extends AbstractServerTest
}
});
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -135,7 +135,7 @@ public class CloseTest extends AbstractServerTest
}
});
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -202,7 +202,7 @@ public class CloseTest extends AbstractServerTest
});
connector.setIdleTimeout(idleTimeout);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);

View File

@ -35,8 +35,8 @@ import org.eclipse.jetty.http2.api.server.ServerSessionListener;
import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.FuturePromise;
import org.eclipse.jetty.util.Promise;
@ -365,9 +365,9 @@ public class DataDemandTest extends AbstractTest
// Generate a lot of small DATA frames and write them in a single
// write so that the server will continuously be notified and demand,
// which will test that it won't throw StackOverflowError.
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
for (int i = 512; i >= 0; --i)
generator.data(accumulator, new DataFrame(clientStream.getId(), ByteBuffer.allocate(1), i == 0), 1);

View File

@ -51,7 +51,7 @@ import org.eclipse.jetty.http2.frames.ResetFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
@ -844,7 +844,7 @@ public abstract class FlowControlStrategyTest
// Now the client is supposed to not send more frames.
// If it does, the connection must be closed.
HTTP2Session http2Session = (HTTP2Session)session;
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
ByteBuffer extraData = ByteBuffer.allocate(1024);
http2Session.getGenerator().data(accumulator, new DataFrame(stream.getId(), extraData, true), extraData.remaining());
List<ByteBuffer> buffers = accumulator.getByteBuffers();
@ -949,7 +949,7 @@ public abstract class FlowControlStrategyTest
// Now the client is supposed to not send more frames.
// If it does, the connection must be closed.
HTTP2Session http2Session = (HTTP2Session)session;
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
ByteBuffer extraData = ByteBuffer.allocate(1024);
http2Session.getGenerator().data(accumulator, new DataFrame(stream.getId(), extraData, true), extraData.remaining());
List<ByteBuffer> buffers = accumulator.getByteBuffers();

View File

@ -38,10 +38,10 @@ import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.ServerConnector;
@ -150,7 +150,7 @@ public class HTTP2CServerTest extends AbstractServerTest
assertTrue(upgrade.toString().startsWith("HTTP/1.1 101 "));
bufferPool = new ArrayRetainableByteBufferPool();
bufferPool = new ArrayByteBufferPool();
generator = new Generator(bufferPool);
final AtomicReference<HeadersFrame> headersRef = new AtomicReference<>();
@ -196,7 +196,7 @@ public class HTTP2CServerTest extends AbstractServerTest
headersRef.set(null);
dataRef.set(null);
latchRef.set(new CountDownLatch(2));
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:" + connector.getLocalPort()), "/two", HttpVersion.HTTP_2, HttpFields.EMPTY, -1);
@ -231,10 +231,10 @@ public class HTTP2CServerTest extends AbstractServerTest
{
final CountDownLatch latch = new CountDownLatch(3);
bufferPool = new ArrayRetainableByteBufferPool();
bufferPool = new ArrayByteBufferPool();
generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:" + connector.getLocalPort()), "/test", HttpVersion.HTTP_2, HttpFields.EMPTY, -1);
@ -328,10 +328,10 @@ public class HTTP2CServerTest extends AbstractServerTest
// Now send an HTTP/2 direct request, which
// will have the PRI * HTTP/2.0 preface.
bufferPool = new ArrayRetainableByteBufferPool();
bufferPool = new ArrayByteBufferPool();
generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
try (Socket client = new Socket("localhost", connector.getLocalPort()))

View File

@ -47,9 +47,9 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.SocketChannelEndPoint;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.Handler;
@ -85,7 +85,7 @@ public class HTTP2ServerTest extends AbstractServerTest
// No preface bytes.
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new HeadersFrame(1, metaData, null, true));
try (Socket client = new Socket("localhost", connector.getLocalPort()))
@ -128,7 +128,7 @@ public class HTTP2ServerTest extends AbstractServerTest
}
});
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -187,7 +187,7 @@ public class HTTP2ServerTest extends AbstractServerTest
}
});
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -255,7 +255,7 @@ public class HTTP2ServerTest extends AbstractServerTest
}
});
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
generator.control(accumulator, new PingFrame(new byte[8], false));
@ -301,7 +301,7 @@ public class HTTP2ServerTest extends AbstractServerTest
}
});
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
generator.control(accumulator, new PingFrame(new byte[8], false));
@ -374,7 +374,7 @@ public class HTTP2ServerTest extends AbstractServerTest
server.addConnector(connector2);
server.start();
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -414,7 +414,7 @@ public class HTTP2ServerTest extends AbstractServerTest
}
});
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -443,7 +443,7 @@ public class HTTP2ServerTest extends AbstractServerTest
{
testRequestWithContinuationFrames(null, () ->
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -458,7 +458,7 @@ public class HTTP2ServerTest extends AbstractServerTest
PriorityFrame priority = new PriorityFrame(1, 13, 200, true);
testRequestWithContinuationFrames(priority, () ->
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -472,7 +472,7 @@ public class HTTP2ServerTest extends AbstractServerTest
{
testRequestWithContinuationFrames(null, () ->
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -494,7 +494,7 @@ public class HTTP2ServerTest extends AbstractServerTest
PriorityFrame priority = new PriorityFrame(1, 13, 200, true);
testRequestWithContinuationFrames(null, () ->
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -515,7 +515,7 @@ public class HTTP2ServerTest extends AbstractServerTest
{
testRequestWithContinuationFrames(null, () ->
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -539,7 +539,7 @@ public class HTTP2ServerTest extends AbstractServerTest
{
testRequestWithContinuationFrames(null, () ->
{
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -560,7 +560,7 @@ public class HTTP2ServerTest extends AbstractServerTest
});
}
private void testRequestWithContinuationFrames(PriorityFrame priorityFrame, Callable<RetainableByteBufferPool.Accumulator> frames) throws Exception
private void testRequestWithContinuationFrames(PriorityFrame priorityFrame, Callable<ByteBufferPool.Accumulator> frames) throws Exception
{
CountDownLatch serverLatch = new CountDownLatch(1);
startServer(new ServerSessionListener()
@ -588,7 +588,7 @@ public class HTTP2ServerTest extends AbstractServerTest
});
generator = new Generator(bufferPool, 4096, 4);
RetainableByteBufferPool.Accumulator accumulator = frames.call();
ByteBufferPool.Accumulator accumulator = frames.call();
try (Socket client = new Socket("localhost", connector.getLocalPort()))
{

View File

@ -67,10 +67,10 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.parser.ServerParser;
import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Request;
@ -111,7 +111,7 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest
assertTrue(http2Client.isStarted());
assertSame(httpClient.getExecutor(), http2Client.getExecutor());
assertSame(httpClient.getScheduler(), http2Client.getScheduler());
assertSame(httpClient.getRetainableByteBufferPool(), http2Client.getRetainableByteBufferPool());
assertSame(httpClient.getByteBufferPool(), http2Client.getByteBufferPool());
assertEquals(httpClient.getConnectTimeout(), http2Client.getConnectTimeout());
assertEquals(httpClient.getIdleTimeout(), http2Client.getIdleTimeout());
assertEquals(httpClient.isUseInputDirectByteBuffers(), http2Client.isUseInputDirectByteBuffers());
@ -541,8 +541,8 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest
resultLatch.countDown();
});
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
Generator generator = new Generator(bufferPool);
try (Socket socket = server.accept())

View File

@ -50,9 +50,9 @@ import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
@ -148,13 +148,13 @@ public class PrefaceTest extends AbstractTest
}
});
RetainableByteBufferPool bufferPool = http2Client.getRetainableByteBufferPool();
ByteBufferPool bufferPool = http2Client.getByteBufferPool();
try (SocketChannel socket = SocketChannel.open())
{
socket.connect(new InetSocketAddress("localhost", connector.getLocalPort()));
Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
Map<Integer, Integer> clientSettings = new HashMap<>();
clientSettings.put(SettingsFrame.ENABLE_PUSH, 0);
@ -247,7 +247,7 @@ public class PrefaceTest extends AbstractTest
});
server.start();
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ByteBufferPool bufferPool = new ArrayByteBufferPool();
try (SocketChannel socket = SocketChannel.open())
{
socket.connect(new InetSocketAddress("localhost", connector.getLocalPort()));
@ -296,7 +296,7 @@ public class PrefaceTest extends AbstractTest
// After the 101, the client must send the connection preface.
Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
Map<Integer, Integer> clientSettings = new HashMap<>();
clientSettings.put(SettingsFrame.ENABLE_PUSH, 1);

View File

@ -33,7 +33,7 @@ import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.http2.frames.ResetFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.FuturePromise;
@ -201,7 +201,7 @@ public class StreamCountTest extends AbstractTest
HeadersFrame frame3 = new HeadersFrame(streamId3, metaData, null, false);
DataFrame data3 = new DataFrame(streamId3, BufferUtil.EMPTY_BUFFER, true);
Generator generator = ((HTTP2Session)session).getGenerator();
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, frame3);
generator.data(accumulator, data3, data3.remaining());
((HTTP2Session)session).getEndPoint().write(Callback.NOOP, accumulator.getByteBuffers().toArray(ByteBuffer[]::new));

View File

@ -64,8 +64,8 @@ import org.eclipse.jetty.http2.internal.HTTP2Flusher;
import org.eclipse.jetty.http2.server.AbstractHTTP2ServerConnectionFactory;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.AbstractEndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.WriteFlusher;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.Handler;
@ -887,7 +887,7 @@ public class StreamResetTest extends AbstractTest
}
});
RetainableByteBufferPool bufferPool = http2Client.getRetainableByteBufferPool();
ByteBufferPool bufferPool = http2Client.getByteBufferPool();
try (SocketChannel socket = SocketChannel.open())
{
String host = "localhost";
@ -895,7 +895,7 @@ public class StreamResetTest extends AbstractTest
socket.connect(new InetSocketAddress(host, port));
Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
Map<Integer, Integer> clientSettings = new HashMap<>();
// Max stream HTTP/2 flow control window.
@ -978,7 +978,7 @@ public class StreamResetTest extends AbstractTest
}
});
RetainableByteBufferPool bufferPool = http2Client.getRetainableByteBufferPool();
ByteBufferPool bufferPool = http2Client.getByteBufferPool();
try (SocketChannel socket = SocketChannel.open())
{
String host = "localhost";
@ -986,7 +986,7 @@ public class StreamResetTest extends AbstractTest
socket.connect(new InetSocketAddress(host, port));
Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator();
ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame());
Map<Integer, Integer> clientSettings = new HashMap<>();
// Max stream HTTP/2 flow control window.

View File

@ -69,7 +69,7 @@ public class HttpClientTransportOverHTTP3 extends AbstractHttpClientTransport im
ClientConnector clientConnector = this.client.getClientConnector();
clientConnector.setExecutor(httpClient.getExecutor());
clientConnector.setScheduler(httpClient.getScheduler());
clientConnector.setRetainableByteBufferPool(httpClient.getRetainableByteBufferPool());
clientConnector.setByteBufferPool(httpClient.getByteBufferPool());
clientConnector.setConnectTimeout(Duration.ofMillis(httpClient.getConnectTimeout()));
clientConnector.setConnectBlocking(httpClient.isConnectBlocking());
clientConnector.setBindAddress(httpClient.getBindAddress());

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.frames.SettingsFrame;
import org.eclipse.jetty.http3.qpack.QpackDecoder;
import org.eclipse.jetty.http3.qpack.QpackEncoder;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.quic.client.ClientProtocolSession;
import org.eclipse.jetty.quic.client.ClientQuicSession;
import org.eclipse.jetty.quic.common.QuicStreamEndPoint;
@ -64,7 +64,7 @@ public class ClientHTTP3Session extends ClientProtocolSession
long encoderStreamId = getQuicSession().newStreamId(StreamType.CLIENT_UNIDIRECTIONAL);
QuicStreamEndPoint encoderEndPoint = openInstructionEndPoint(encoderStreamId);
InstructionFlusher encoderInstructionFlusher = new InstructionFlusher(quicSession, encoderEndPoint, EncoderStreamConnection.STREAM_TYPE);
RetainableByteBufferPool bufferPool = quicSession.getRetainableByteBufferPool();
ByteBufferPool bufferPool = quicSession.getByteBufferPool();
this.encoder = new QpackEncoder(bufferPool, new InstructionHandler(encoderInstructionFlusher), configuration.getMaxBlockedStreams());
addBean(encoder);
if (LOG.isDebugEnabled())
@ -85,7 +85,7 @@ public class ClientHTTP3Session extends ClientProtocolSession
if (LOG.isDebugEnabled())
LOG.debug("created control stream #{} on {}", controlStreamId, controlEndPoint);
this.messageFlusher = new MessageFlusher(quicSession.getRetainableByteBufferPool(), encoder, configuration.getMaxRequestHeadersSize(), configuration.isUseOutputDirectByteBuffers());
this.messageFlusher = new MessageFlusher(quicSession.getByteBufferPool(), encoder, configuration.getMaxRequestHeadersSize(), configuration.isUseOutputDirectByteBuffers());
addBean(messageFlusher);
}
@ -199,7 +199,7 @@ public class ClientHTTP3Session extends ClientProtocolSession
private void openUnidirectionalStreamEndPoint(QuicStreamEndPoint endPoint)
{
UnidirectionalStreamConnection connection = new UnidirectionalStreamConnection(endPoint, getQuicSession().getExecutor(), getQuicSession().getRetainableByteBufferPool(), encoder, decoder, session);
UnidirectionalStreamConnection connection = new UnidirectionalStreamConnection(endPoint, getQuicSession().getExecutor(), getQuicSession().getByteBufferPool(), encoder, decoder, session);
endPoint.setConnection(connection);
endPoint.opened();
}

Some files were not shown because too many files have changed in this diff Show More