You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/02/02 19:43:52 UTC
svn commit: r1781463 [1/2] - in /httpcomponents/httpcore/trunk:
httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/
httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/
httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/ ht...
Author: olegk
Date: Thu Feb 2 19:43:52 2017
New Revision: 1781463
URL: http://svn.apache.org/viewvc?rev=1781463&view=rev
Log:
Configuration improvements
Added:
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/CharCodingConfig.java (contents, props changed)
- copied, changed from r1781462, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/CharCodingSupport.java (contents, props changed)
- copied, changed from r1781462, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/ConnSupport.java
Removed:
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/ConnSupport.java
Modified:
httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkConnection.java
httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java
httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/HttpServer.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiatorFactory.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamMultiplexer.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/bootstrap/ServerBootstrap.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1IOEventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParserFactory.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParserFactory.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/RequesterBootstrap.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/ServerBootstrap.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/NHttpMessageParserFactory.java
httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
Modified: httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkConnection.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkConnection.java Thu Feb 2 19:43:52 2017
@@ -30,18 +30,19 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
+import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection;
import org.apache.hc.core5.http.io.SessionInputBuffer;
import org.apache.hc.core5.http.io.SessionOutputBuffer;
-import org.apache.hc.core5.function.Supplier;
class BenchmarkConnection extends DefaultBHttpClientConnection {
private final Stats stats;
- BenchmarkConnection(final int bufsize, final Stats stats) {
- super(bufsize);
+ BenchmarkConnection(final H1Config h1Config, final Stats stats) {
+ super(h1Config);
this.stats = stats;
}
Modified: httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java Thu Feb 2 19:43:52 2017
@@ -46,6 +46,7 @@ import org.apache.hc.core5.http.HttpExce
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
import org.apache.hc.core5.http.io.entity.EntityUtils;
@@ -107,7 +108,7 @@ class BenchmarkWorker implements Runnabl
public void run() {
ClassicHttpResponse response = null;
final HttpVersion version = config.isUseHttp1_0() ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
- final BenchmarkConnection conn = new BenchmarkConnection(8 * 1024, stats);
+ final BenchmarkConnection conn = new BenchmarkConnection(H1Config.DEFAULT, stats);
final String scheme = this.host.getSchemeName();
final String hostname = this.host.getHostName();
Modified: httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/HttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/HttpServer.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/HttpServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/HttpServer.java Thu Feb 2 19:43:52 2017
@@ -35,7 +35,7 @@ import java.net.Socket;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.io.DefaultBHttpServerConnection;
import org.apache.hc.core5.http.impl.io.DefaultClassicHttpResponseFactory;
@@ -65,12 +65,10 @@ public class HttpServer {
public HttpServer() throws IOException {
super();
this.httpproc = new DefaultHttpProcessor(
- new HttpResponseInterceptor[] {
- new ResponseDate(),
- new ResponseServer("TEST-SERVER/1.1"),
- new ResponseContent(),
- new ResponseConnControl()
- });
+ new ResponseDate(),
+ new ResponseServer("TEST-SERVER/1.1"),
+ new ResponseContent(),
+ new ResponseConnControl());
this.reqistry = new UriHttpRequestHandlerMapper();
this.serversocket = new ServerSocket(0);
}
@@ -83,7 +81,7 @@ public class HttpServer {
private HttpServerConnection acceptConnection() throws IOException {
final Socket socket = this.serversocket.accept();
- final DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(8 * 1024);
+ final DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(H1Config.DEFAULT);
conn.bind(socket);
return conn;
}
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java Thu Feb 2 19:43:52 2017
@@ -53,17 +53,24 @@ public final class HPackDecoder {
private CharBuffer tmpBuf;
private int maxTableSize;
- HPackDecoder(final InboundDynamicTable dynamicTable, final Charset charset) {
- Args.notNull(charset, "Charset");
+ HPackDecoder(final InboundDynamicTable dynamicTable, final CharsetDecoder charsetDecoder) {
this.dynamicTable = dynamicTable != null ? dynamicTable : new InboundDynamicTable();
this.contentBuf = new ByteArrayBuffer(256);
- this.charsetDecoder = charset.equals(StandardCharsets.US_ASCII) || charset.equals(StandardCharsets.ISO_8859_1) ? null : charset.newDecoder();
+ this.charsetDecoder = charsetDecoder;
+ }
+
+ HPackDecoder(final InboundDynamicTable dynamicTable, final Charset charset) {
+ this(dynamicTable, charset != null && !StandardCharsets.US_ASCII.equals(charset) ? charset.newDecoder() : null);
}
public HPackDecoder(final Charset charset) {
this(new InboundDynamicTable(), charset);
}
+ public HPackDecoder(final CharsetDecoder charsetDecoder) {
+ this(new InboundDynamicTable(), charsetDecoder);
+ }
+
static int readByte(final ByteBuffer src) throws HPackException {
if (!src.hasRemaining()) {
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java Thu Feb 2 19:43:52 2017
@@ -49,17 +49,24 @@ public final class HPackEncoder {
private ByteBuffer tmpBuf;
private int maxTableSize;
- HPackEncoder(final OutboundDynamicTable dynamicTable, final Charset charset) {
- Args.notNull(charset, "Charset");
+ HPackEncoder(final OutboundDynamicTable dynamicTable, final CharsetEncoder charsetEncoder) {
this.dynamicTable = dynamicTable != null ? dynamicTable : new OutboundDynamicTable();
this.huffmanBuf = new ByteArrayBuffer(128);
- this.charsetEncoder = charset.equals(StandardCharsets.US_ASCII) || charset.equals(StandardCharsets.ISO_8859_1) ? null : charset.newEncoder();
+ this.charsetEncoder = charsetEncoder;
+ }
+
+ HPackEncoder(final OutboundDynamicTable dynamicTable, final Charset charset) {
+ this(dynamicTable, charset != null && !StandardCharsets.US_ASCII.equals(charset) ? charset.newEncoder() : null);
}
public HPackEncoder(final Charset charset) {
this(new OutboundDynamicTable(), charset);
}
+ public HPackEncoder(final CharsetEncoder charsetEncoder) {
+ this(new OutboundDynamicTable(), charsetEncoder);
+ }
+
static void encodeInt(final ByteArrayBuffer dst, final int n, final int i, final int mask) {
final int nbits = 0xFF >>> (8 - n);
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java Thu Feb 2 19:43:52 2017
@@ -31,8 +31,6 @@ import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
@@ -53,8 +51,10 @@ import org.apache.hc.core5.http.HttpExce
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.BasicEndpointDetails;
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
+import org.apache.hc.core5.http.impl.CharCodingSupport;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
import org.apache.hc.core5.http.nio.AsyncPushProducer;
@@ -133,7 +133,7 @@ abstract class AbstractHttp2StreamMultip
final FrameFactory frameFactory,
final StreamIdGenerator idGenerator,
final HttpProcessor httpProcessor,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final ConnectionListener connectionListener,
final Http2StreamListener streamListener) {
@@ -153,8 +153,8 @@ abstract class AbstractHttp2StreamMultip
this.outputLock = new ReentrantLock();
this.outputRequests = new AtomicInteger(0);
this.lastStreamId = new AtomicInteger(0);
- this.hPackEncoder = new HPackEncoder(charset != null ? charset : StandardCharsets.US_ASCII);
- this.hPackDecoder = new HPackDecoder(charset != null ? charset : StandardCharsets.US_ASCII);
+ this.hPackEncoder = new HPackEncoder(CharCodingSupport.createEncoder(charCodingConfig));
+ this.hPackDecoder = new HPackDecoder(CharCodingSupport.createDecoder(charCodingConfig));
this.streamMap = new ConcurrentHashMap<>();
this.connInputWindow = new AtomicInteger(localConfig.getInitialWindowSize());
this.connOutputWindow = new AtomicInteger(H2Config.DEFAULT.getInitialWindowSize());
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java Thu Feb 2 19:43:52 2017
@@ -27,8 +27,8 @@
package org.apache.hc.core5.http2.impl.nio;
import java.io.IOException;
-import java.nio.charset.Charset;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
@@ -55,11 +55,11 @@ public class ClientHttp2StreamMultiplexe
final FrameFactory frameFactory,
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final ConnectionListener connectionListener,
final Http2StreamListener streamListener) {
- super(Mode.CLIENT, ioSession, frameFactory, StreamIdGenerator.ODD, httpProcessor, charset,
+ super(Mode.CLIENT, ioSession, frameFactory, StreamIdGenerator.ODD, httpProcessor, charCodingConfig,
h2Config, connectionListener, streamListener);
this.pushHandlerFactory = pushHandlerFactory;
}
@@ -68,18 +68,18 @@ public class ClientHttp2StreamMultiplexe
final IOSession ioSession,
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config) {
- this(ioSession, DefaultFrameFactory.INSTANCE, httpProcessor, pushHandlerFactory, charset,
+ this(ioSession, DefaultFrameFactory.INSTANCE, httpProcessor, pushHandlerFactory, charCodingConfig,
h2Config, null, null);
}
public ClientHttp2StreamMultiplexer(
final IOSession ioSession,
final HttpProcessor httpProcessor,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config) {
- this(ioSession, httpProcessor, null, charset, h2Config);
+ this(ioSession, httpProcessor, null, charCodingConfig, h2Config);
}
@Override
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java Thu Feb 2 19:43:52 2017
@@ -32,13 +32,12 @@ import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.EndpointDetails;
import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.impl.nio.HttpConnectionEventHandler;
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
@@ -67,7 +66,7 @@ public class ClientHttpProtocolNegotiato
private final IOSession ioSession;
private final HttpProcessor httpProcessor;
- private final Charset charset;
+ private final CharCodingConfig charCodingConfig;
private final H2Config h2Config;
private final HandlerFactory<AsyncPushConsumer> pushHandlerFactory;
private final ConnectionListener connectionListener;
@@ -78,14 +77,14 @@ public class ClientHttpProtocolNegotiato
final IOSession ioSession,
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final ConnectionListener connectionListener,
final Http2StreamListener streamListener) {
this.ioSession = Args.notNull(ioSession, "I/O session");
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.pushHandlerFactory = pushHandlerFactory;
- this.charset = charset != null ? charset : StandardCharsets.US_ASCII;
+ this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
this.h2Config = h2Config != null ? h2Config : H2Config.DEFAULT;
this.streamListener = streamListener;
this.connectionListener = connectionListener;
@@ -94,7 +93,7 @@ public class ClientHttpProtocolNegotiato
protected ClientHttp2StreamMultiplexer createStreamMultiplexer(final IOSession ioSession) {
return new ClientHttp2StreamMultiplexer(ioSession, DefaultFrameFactory.INSTANCE, httpProcessor,
- pushHandlerFactory, charset, h2Config, connectionListener, streamListener);
+ pushHandlerFactory, charCodingConfig, h2Config, connectionListener, streamListener);
}
@Override
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiatorFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiatorFactory.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiatorFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiatorFactory.java Thu Feb 2 19:43:52 2017
@@ -27,11 +27,9 @@
package org.apache.hc.core5.http2.impl.nio;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.HandlerFactory;
@@ -49,7 +47,7 @@ public class ClientHttpProtocolNegotiato
private final HttpProcessor httpProcessor;
private final HandlerFactory<AsyncPushConsumer> pushHandlerFactory;
- private final Charset charset;
+ private final CharCodingConfig charCodingConfig;
private final H2Config h2Config;
private final ConnectionListener connectionListener;
private final Http2StreamListener streamListener;
@@ -57,13 +55,13 @@ public class ClientHttpProtocolNegotiato
public ClientHttpProtocolNegotiatorFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final ConnectionListener connectionListener,
final Http2StreamListener streamListener) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.pushHandlerFactory = pushHandlerFactory;
- this.charset = charset != null ? charset : StandardCharsets.US_ASCII;
+ this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
this.h2Config = h2Config != null ? h2Config : H2Config.DEFAULT;
this.connectionListener = connectionListener;
this.streamListener = streamListener;
@@ -87,7 +85,7 @@ public class ClientHttpProtocolNegotiato
@Override
public ClientHttpProtocolNegotiator createHandler(final IOSession ioSession) {
return new ClientHttpProtocolNegotiator(ioSession, httpProcessor, pushHandlerFactory,
- charset, h2Config, connectionListener, streamListener);
+ charCodingConfig, h2Config, connectionListener, streamListener);
}
}
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamMultiplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamMultiplexer.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamMultiplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamMultiplexer.java Thu Feb 2 19:43:52 2017
@@ -27,8 +27,8 @@
package org.apache.hc.core5.http2.impl.nio;
import java.io.IOException;
-import java.nio.charset.Charset;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
@@ -56,11 +56,11 @@ public class ServerHttp2StreamMultiplexe
final FrameFactory frameFactory,
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final ConnectionListener connectionListener,
final Http2StreamListener streamListener) {
- super(Mode.SERVER, ioSession, frameFactory, StreamIdGenerator.EVEN, httpProcessor, charset,
+ super(Mode.SERVER, ioSession, frameFactory, StreamIdGenerator.EVEN, httpProcessor, charCodingConfig,
h2Config, connectionListener, streamListener);
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Handler factory");
}
@@ -69,9 +69,9 @@ public class ServerHttp2StreamMultiplexe
final IOSession ioSession,
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config) {
- this(ioSession, DefaultFrameFactory.INSTANCE, httpProcessor, exchangeHandlerFactory, charset,
+ this(ioSession, DefaultFrameFactory.INSTANCE, httpProcessor, exchangeHandlerFactory, charCodingConfig,
h2Config, null, null);
}
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java Thu Feb 2 19:43:52 2017
@@ -31,13 +31,12 @@ import java.io.IOException;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.EndpointDetails;
import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.impl.nio.HttpConnectionEventHandler;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
@@ -61,7 +60,7 @@ public class ServerHttpProtocolNegotiato
private final IOSession ioSession;
private final HttpProcessor httpProcessor;
private final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory;
- private final Charset charset;
+ private final CharCodingConfig charCodingConfig;
private final H2Config h2Config;
private final ByteBuffer bytebuf;
private final ConnectionListener connectionListener;
@@ -71,14 +70,14 @@ public class ServerHttpProtocolNegotiato
final IOSession ioSession,
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final ConnectionListener connectionListener,
final Http2StreamListener streamListener) {
this.ioSession = Args.notNull(ioSession, "I/O session");
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
- this.charset = charset != null ? charset : StandardCharsets.US_ASCII;
+ this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
this.h2Config = h2Config != null ? h2Config : H2Config.DEFAULT;
this.bytebuf = ByteBuffer.allocate(1024);
this.connectionListener = connectionListener;
@@ -87,7 +86,7 @@ public class ServerHttpProtocolNegotiato
protected ServerHttp2StreamMultiplexer createStreamMultiplexer(final IOSession ioSession) {
return new ServerHttp2StreamMultiplexer(ioSession, DefaultFrameFactory.INSTANCE, httpProcessor,
- exchangeHandlerFactory, charset, h2Config, connectionListener, streamListener);
+ exchangeHandlerFactory, charCodingConfig, h2Config, connectionListener, streamListener);
}
@Override
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java Thu Feb 2 19:43:52 2017
@@ -27,11 +27,9 @@
package org.apache.hc.core5.http2.impl.nio;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
import org.apache.hc.core5.http.nio.HandlerFactory;
@@ -51,7 +49,7 @@ public class ServerHttpProtocolNegotiato
private final HttpProcessor httpProcessor;
private final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory;
- private final Charset charset;
+ private final CharCodingConfig charCodingConfig;
private final H2Config h2Config;
private final TlsStrategy tlsStrategy;
private final ConnectionListener connectionListener;
@@ -60,14 +58,14 @@ public class ServerHttpProtocolNegotiato
public ServerHttpProtocolNegotiatorFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final TlsStrategy tlsStrategy,
final ConnectionListener connectionListener,
final Http2StreamListener streamListener) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
- this.charset = charset != null ? charset : StandardCharsets.US_ASCII;
+ this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
this.h2Config = h2Config != null ? h2Config : H2Config.DEFAULT;
this.tlsStrategy = tlsStrategy;
this.connectionListener = connectionListener;
@@ -93,7 +91,7 @@ public class ServerHttpProtocolNegotiato
ioSession.getRemoteAddress());
}
return new ServerHttpProtocolNegotiator(ioSession, httpProcessor, exchangeHandlerFactory,
- charset, h2Config, connectionListener, streamListener);
+ charCodingConfig, h2Config, connectionListener, streamListener);
}
}
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java Thu Feb 2 19:43:52 2017
@@ -26,8 +26,6 @@
*/
package org.apache.hc.core5.http2.impl.nio.bootstrap;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -35,6 +33,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.ExceptionListener;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.impl.nio.bootstrap.ClientEndpoint;
import org.apache.hc.core5.http.impl.nio.bootstrap.HttpAsyncRequester;
@@ -61,7 +60,7 @@ public class H2RequesterBootstrap {
private IOReactorConfig ioReactorConfig;
private HttpProcessor httpProcessor;
- private Charset charset;
+ private CharCodingConfig charCodingConfig;
private H2Config h2Config;
private int defaultMaxPerRoute;
private int maxTotal;
@@ -107,10 +106,10 @@ public class H2RequesterBootstrap {
}
/**
- * Sets charset for HTTP/2 messages.
+ * Sets char coding for HTTP/2 messages.
*/
- public final H2RequesterBootstrap setCharset(final Charset charset) {
- this.charset = charset;
+ public final H2RequesterBootstrap setCharCodingConfig(final CharCodingConfig charCodingConfig) {
+ this.charCodingConfig = charCodingConfig;
return this;
}
@@ -207,7 +206,7 @@ public class H2RequesterBootstrap {
final ClientHttpProtocolNegotiatorFactory ioEventHandlerFactory = new ClientHttpProtocolNegotiatorFactory(
httpProcessor != null ? httpProcessor : Http2Processors.client(),
pushConsumerRegistry,
- charset != null ? charset : StandardCharsets.US_ASCII,
+ charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT,
h2Config != null ? h2Config : H2Config.DEFAULT,
connectionListener,
streamListener);
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java Thu Feb 2 19:43:52 2017
@@ -26,13 +26,12 @@
*/
package org.apache.hc.core5.http2.impl.nio.bootstrap;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.ExceptionListener;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.impl.nio.bootstrap.AsyncServerExchangeHandlerRegistry;
import org.apache.hc.core5.http.impl.nio.bootstrap.HttpAsyncServer;
@@ -60,7 +59,7 @@ public class H2ServerBootstrap {
private String canonicalHostName;
private IOReactorConfig ioReactorConfig;
private HttpProcessor httpProcessor;
- private Charset charset;
+ private CharCodingConfig charCodingConfig;
private H2Config h2Config;
private TlsStrategy tlsStrategy;
private ExceptionListener exceptionListener;
@@ -110,10 +109,10 @@ public class H2ServerBootstrap {
}
/**
- * Sets charset for HTTP/2 messages.
+ * Sets char coding for HTTP/2 messages.
*/
- public final H2ServerBootstrap setCharset(final Charset charset) {
- this.charset = charset;
+ public final H2ServerBootstrap setCharset(final CharCodingConfig charCodingConfig) {
+ this.charCodingConfig = charCodingConfig;
return this;
}
@@ -204,7 +203,7 @@ public class H2ServerBootstrap {
final ServerHttpProtocolNegotiatorFactory ioEventHandlerFactory = new ServerHttpProtocolNegotiatorFactory(
httpProcessor != null ? httpProcessor : Http2Processors.server(),
exchangeHandlerFactory,
- charset != null ? charset : StandardCharsets.US_ASCII,
+ charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT,
h2Config != null ? h2Config : H2Config.DEFAULT,
tlsStrategy != null ? tlsStrategy : new H2ServerTlsStrategy(new int[] {443, 8443}),
connectionListener,
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java Thu Feb 2 19:43:52 2017
@@ -35,6 +35,7 @@ import org.apache.hc.core5.http.ClassicH
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection;
import org.apache.hc.core5.http.impl.io.bootstrap.HttpRequester;
import org.apache.hc.core5.http.impl.io.bootstrap.RequesterBootstrap;
@@ -55,7 +56,7 @@ public class ClassicTestClient {
public ClassicTestClient() {
super();
- this.connection = new DefaultBHttpClientConnection(8192);
+ this.connection = new DefaultBHttpClientConnection(H1Config.DEFAULT);
}
public void setHttpProcessor(final HttpProcessor httpProcessor) {
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java Thu Feb 2 19:43:52 2017
@@ -35,6 +35,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.ExceptionListener;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.config.SocketConfig;
import org.apache.hc.core5.http.impl.io.bootstrap.HttpServer;
import org.apache.hc.core5.http.impl.io.bootstrap.ServerBootstrap;
@@ -124,7 +125,7 @@ public class ClassicTestServer {
@Override
public LoggingBHttpServerConnection createConnection(final Socket socket) throws IOException {
- final LoggingBHttpServerConnection conn = new LoggingBHttpServerConnection(8 * 1024);
+ final LoggingBHttpServerConnection conn = new LoggingBHttpServerConnection(H1Config.DEFAULT);
conn.bind(socket);
return conn;
}
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java Thu Feb 2 19:43:52 2017
@@ -57,16 +57,15 @@ public class LoggingBHttpClientConnectio
private final Wire wire;
public LoggingBHttpClientConnection(
- final int buffersize,
+ final H1Config h1Config,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
- final H1Config h1Config,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
- super(buffersize, chardecoder, charencoder,
- h1Config, incomingContentStrategy, outgoingContentStrategy,
+ super(h1Config, chardecoder, charencoder,
+ incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = "http-outgoing-" + COUNT.incrementAndGet();
this.log = LogManager.getLogger(getClass());
@@ -74,8 +73,8 @@ public class LoggingBHttpClientConnectio
this.wire = new Wire(LogManager.getLogger("org.apache.http.wire"), this.id);
}
- public LoggingBHttpClientConnection(final int buffersize) {
- this(buffersize, null, null, null, null, null, null, null);
+ public LoggingBHttpClientConnection(final H1Config h1Config) {
+ this(h1Config, null, null, null, null, null, null);
}
@Override
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java Thu Feb 2 19:43:52 2017
@@ -56,15 +56,14 @@ public class LoggingBHttpServerConnectio
private final Wire wire;
public LoggingBHttpServerConnection(
- final int buffersize,
+ final H1Config h1Config,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
- final H1Config h1Config,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory,
final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory) {
- super(buffersize, chardecoder, charencoder, h1Config,
+ super(h1Config, chardecoder, charencoder,
incomingContentStrategy, outgoingContentStrategy,
requestParserFactory, responseWriterFactory);
this.id = "http-incoming-" + COUNT.incrementAndGet();
@@ -73,8 +72,8 @@ public class LoggingBHttpServerConnectio
this.wire = new Wire(LogManager.getLogger("org.apache.http.wire"), this.id);
}
- public LoggingBHttpServerConnection(final int buffersize) {
- this(buffersize, null, null, null, null, null, null, null);
+ public LoggingBHttpServerConnection(final H1Config h1Config) {
+ this(h1Config, null, null, null, null, null, null);
}
@Override
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java Thu Feb 2 19:43:52 2017
@@ -39,7 +39,7 @@ import org.apache.hc.core5.concurrent.Fu
import org.apache.hc.core5.function.Callback;
import org.apache.hc.core5.http.ExceptionListener;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.HttpProcessors;
@@ -84,22 +84,17 @@ public class Http1TestClient extends Asy
public void start(
final HttpProcessor httpProcessor,
- final H1Config h1Config,
- final ConnectionConfig connectionConfig) throws IOException {
+ final H1Config h1Config) throws IOException {
execute(new InternalClientHttp1EventHandlerFactory(
httpProcessor,
h1Config,
- connectionConfig,
+ CharCodingConfig.DEFAULT,
DefaultConnectionReuseStrategy.INSTANCE,
sslContext));
}
- public void start(final H1Config h1Config, final ConnectionConfig connectionConfig) throws IOException {
- start(HttpProcessors.client(), h1Config, connectionConfig);
- }
-
public void start(final H1Config h1Config) throws IOException {
- start(h1Config, ConnectionConfig.DEFAULT);
+ start(HttpProcessors.client(), h1Config);
}
public void start() throws IOException {
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestServer.java Thu Feb 2 19:43:52 2017
@@ -35,7 +35,7 @@ import javax.net.ssl.SSLContext;
import org.apache.hc.core5.function.Callback;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.ExceptionListener;
-import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.HttpProcessors;
@@ -115,7 +115,7 @@ public class Http1TestServer extends Asy
httpProcessor,
handlerRegistry,
h1Config,
- ConnectionConfig.DEFAULT,
+ CharCodingConfig.DEFAULT,
DefaultConnectionReuseStrategy.INSTANCE,
sslContext));
}
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java Thu Feb 2 19:43:52 2017
@@ -41,20 +41,22 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpConnection;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.H1Config;
+import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
+import org.apache.hc.core5.http.impl.Http1StreamListener;
import org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler;
import org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer;
-import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.impl.nio.DefaultHttpRequestWriterFactory;
import org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParserFactory;
-import org.apache.hc.core5.http.impl.Http1StreamListener;
import org.apache.hc.core5.http.message.RequestLine;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.http.nio.NHttpMessageParser;
+import org.apache.hc.core5.http.nio.NHttpMessageParserFactory;
import org.apache.hc.core5.http.nio.NHttpMessageWriter;
+import org.apache.hc.core5.http.nio.NHttpMessageWriterFactory;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
@@ -76,29 +78,33 @@ class InternalClientHttp1EventHandlerFac
private final HttpProcessor httpProcessor;
private final H1Config h1Config;
- private final ConnectionConfig connectionConfig;
+ private final CharCodingConfig charCodingConfig;
private final ConnectionReuseStrategy connectionReuseStrategy;
private final SSLContext sslContext;
+ private final NHttpMessageParserFactory<HttpResponse> responseParserFactory;
+ private final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory;
InternalClientHttp1EventHandlerFactory(
final HttpProcessor httpProcessor,
final H1Config h1Config,
- final ConnectionConfig connectionConfig,
+ final CharCodingConfig charCodingConfig,
final ConnectionReuseStrategy connectionReuseStrategy,
final SSLContext sslContext) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
- this.connectionConfig = connectionConfig != null ? connectionConfig: ConnectionConfig.DEFAULT;
+ this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
DefaultConnectionReuseStrategy.INSTANCE;
this.sslContext = sslContext;
+ this.responseParserFactory = new DefaultHttpResponseParserFactory(this.h1Config);
+ this.requestWriterFactory = DefaultHttpRequestWriterFactory.INSTANCE;
}
protected ClientHttp1StreamDuplexer createClientHttp1StreamDuplexer(
final IOSession ioSession,
final HttpProcessor httpProcessor,
final H1Config h1Config,
- final ConnectionConfig connectionConfig,
+ final CharCodingConfig charCodingConfig,
final ConnectionReuseStrategy connectionReuseStrategy,
final NHttpMessageParser<HttpResponse> incomingMessageParser,
final NHttpMessageWriter<HttpRequest> outgoingMessageWriter,
@@ -106,7 +112,7 @@ class InternalClientHttp1EventHandlerFac
final ContentLengthStrategy outgoingContentStrategy,
final ConnectionListener connectionListener,
final Http1StreamListener streamListener) {
- return new ClientHttp1StreamDuplexer(ioSession, httpProcessor, h1Config, connectionConfig,
+ return new ClientHttp1StreamDuplexer(ioSession, httpProcessor, h1Config, charCodingConfig,
connectionReuseStrategy, incomingMessageParser, outgoingMessageWriter,
incomingContentStrategy, outgoingContentStrategy,
connectionListener, streamListener);
@@ -125,10 +131,10 @@ class InternalClientHttp1EventHandlerFac
new LoggingIOSession(ioSession, id, sessionLog, wireLog),
httpProcessor,
h1Config,
- connectionConfig,
+ charCodingConfig,
connectionReuseStrategy,
- DefaultHttpResponseParserFactory.INSTANCE.create(h1Config),
- DefaultHttpRequestWriterFactory.INSTANCE.create(),
+ responseParserFactory.create(),
+ requestWriterFactory.create(),
DefaultContentLengthStrategy.INSTANCE,
DefaultContentLengthStrategy.INSTANCE,
new ConnectionListener() {
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java Thu Feb 2 19:43:52 2017
@@ -41,14 +41,14 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpConnection;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.H1Config;
+import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
-import org.apache.hc.core5.http.impl.ConnectionListener;
+import org.apache.hc.core5.http.impl.Http1StreamListener;
import org.apache.hc.core5.http.impl.nio.DefaultHttpRequestParserFactory;
import org.apache.hc.core5.http.impl.nio.DefaultHttpResponseWriterFactory;
-import org.apache.hc.core5.http.impl.Http1StreamListener;
import org.apache.hc.core5.http.impl.nio.ServerHttp1IOEventHandler;
import org.apache.hc.core5.http.impl.nio.ServerHttp1StreamDuplexer;
import org.apache.hc.core5.http.message.RequestLine;
@@ -56,7 +56,9 @@ import org.apache.hc.core5.http.message.
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
import org.apache.hc.core5.http.nio.HandlerFactory;
import org.apache.hc.core5.http.nio.NHttpMessageParser;
+import org.apache.hc.core5.http.nio.NHttpMessageParserFactory;
import org.apache.hc.core5.http.nio.NHttpMessageWriter;
+import org.apache.hc.core5.http.nio.NHttpMessageWriterFactory;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
@@ -79,24 +81,28 @@ class InternalServerHttp1EventHandlerFac
private final HttpProcessor httpProcessor;
private final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory;
private final H1Config h1Config;
- private final ConnectionConfig connectionConfig;
+ private final CharCodingConfig charCodingConfig;
private final ConnectionReuseStrategy connectionReuseStrategy;
private final SSLContext sslContext;
+ private final NHttpMessageParserFactory<HttpRequest> requestParserFactory;
+ private final NHttpMessageWriterFactory<HttpResponse> responseWriterFactory;
InternalServerHttp1EventHandlerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
final H1Config h1Config,
- final ConnectionConfig connectionConfig,
+ final CharCodingConfig charCodingConfig,
final ConnectionReuseStrategy connectionReuseStrategy,
final SSLContext sslContext) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
- this.connectionConfig = connectionConfig != null ? connectionConfig: ConnectionConfig.DEFAULT;
+ this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
DefaultConnectionReuseStrategy.INSTANCE;
this.sslContext = sslContext;
+ this.requestParserFactory = new DefaultHttpRequestParserFactory(this.h1Config);
+ this.responseWriterFactory = DefaultHttpResponseWriterFactory.INSTANCE;
}
protected ServerHttp1StreamDuplexer createServerHttp1StreamDuplexer(
@@ -104,7 +110,7 @@ class InternalServerHttp1EventHandlerFac
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
final H1Config h1Config,
- final ConnectionConfig connectionConfig,
+ final CharCodingConfig charCodingConfig,
final ConnectionReuseStrategy connectionReuseStrategy,
final NHttpMessageParser<HttpRequest> incomingMessageParser,
final NHttpMessageWriter<HttpResponse> outgoingMessageWriter,
@@ -113,7 +119,7 @@ class InternalServerHttp1EventHandlerFac
final ConnectionListener connectionListener,
final Http1StreamListener streamListener) {
return new ServerHttp1StreamDuplexer(ioSession, httpProcessor, exchangeHandlerFactory, h1Config,
- connectionConfig, connectionReuseStrategy, incomingMessageParser, outgoingMessageWriter,
+ charCodingConfig, connectionReuseStrategy, incomingMessageParser, outgoingMessageWriter,
incomingContentStrategy, outgoingContentStrategy, connectionListener, streamListener);
}
@@ -132,10 +138,10 @@ class InternalServerHttp1EventHandlerFac
httpProcessor,
exchangeHandlerFactory,
h1Config,
- connectionConfig,
+ charCodingConfig,
connectionReuseStrategy,
- DefaultHttpRequestParserFactory.INSTANCE.create(h1Config),
- DefaultHttpResponseWriterFactory.INSTANCE.create(),
+ requestParserFactory.create(),
+ responseWriterFactory.create(),
DefaultContentLengthStrategy.INSTANCE,
DefaultContentLengthStrategy.INSTANCE,
new ConnectionListener() {
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java Thu Feb 2 19:43:52 2017
@@ -29,7 +29,6 @@ package org.apache.hc.core5.testing.nio.
import java.io.IOException;
import java.net.SocketTimeoutException;
-import java.nio.charset.StandardCharsets;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -41,6 +40,7 @@ import org.apache.hc.core5.function.Call
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.ExceptionListener;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.nio.bootstrap.AsyncRequester;
import org.apache.hc.core5.http.impl.nio.bootstrap.ClientEndpoint;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
@@ -104,7 +104,7 @@ public class Http2TestClient extends Asy
start(new InternalClientHttp2EventHandlerFactory(
httpProcessor,
pushConsumerRegistry,
- StandardCharsets.US_ASCII,
+ CharCodingConfig.DEFAULT,
h2Config,
sslContext));
}
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestServer.java Thu Feb 2 19:43:52 2017
@@ -29,13 +29,13 @@ package org.apache.hc.core5.testing.nio.
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.nio.charset.StandardCharsets;
import javax.net.ssl.SSLContext;
import org.apache.hc.core5.function.Callback;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.ExceptionListener;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.nio.bootstrap.AsyncServer;
import org.apache.hc.core5.http.impl.nio.bootstrap.AsyncServerExchangeHandlerRegistry;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
@@ -45,8 +45,8 @@ import org.apache.hc.core5.http.nio.supp
import org.apache.hc.core5.http.nio.support.RequestConsumerSupplier;
import org.apache.hc.core5.http.nio.support.ResponseHandler;
import org.apache.hc.core5.http.protocol.HttpProcessor;
-import org.apache.hc.core5.http2.impl.Http2Processors;
import org.apache.hc.core5.http2.config.H2Config;
+import org.apache.hc.core5.http2.impl.Http2Processors;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.IOSession;
@@ -114,7 +114,7 @@ public class Http2TestServer extends Asy
start(new InternalServerHttp2EventHandlerFactory(
httpProcessor,
handlerRegistry,
- StandardCharsets.US_ASCII,
+ CharCodingConfig.DEFAULT,
h2Config,
sslContext));
final ListenerEndpoint listener = listen(new InetSocketAddress(0));
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java Thu Feb 2 19:43:52 2017
@@ -27,13 +27,13 @@
package org.apache.hc.core5.testing.nio.http2;
-import java.nio.charset.Charset;
import java.util.concurrent.atomic.AtomicLong;
import javax.net.ssl.SSLContext;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.HttpConnection;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.HandlerFactory;
@@ -57,19 +57,19 @@ class InternalClientHttp2EventHandlerFac
private final HttpProcessor httpProcessor;
private final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory;
- private final Charset charset;
+ private final CharCodingConfig charCodingConfig;
private final H2Config h2Config;
private final SSLContext sslContext;
InternalClientHttp2EventHandlerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final SSLContext sslContext) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = exchangeHandlerFactory;
- this.charset = charset;
+ this.charCodingConfig = charCodingConfig;
this.h2Config = h2Config;
this.sslContext = sslContext;
}
@@ -82,7 +82,7 @@ class InternalClientHttp2EventHandlerFac
}
final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
return new LoggingIOEventHandler(new ClientHttpProtocolNegotiator(
- ioSession, httpProcessor, exchangeHandlerFactory, charset, h2Config,
+ ioSession, httpProcessor, exchangeHandlerFactory, charCodingConfig, h2Config,
new ConnectionListener() {
@Override
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java Thu Feb 2 19:43:52 2017
@@ -27,13 +27,13 @@
package org.apache.hc.core5.testing.nio.http2;
-import java.nio.charset.Charset;
import java.util.concurrent.atomic.AtomicLong;
import javax.net.ssl.SSLContext;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.HttpConnection;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.impl.ConnectionListener;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
import org.apache.hc.core5.http.nio.HandlerFactory;
@@ -57,19 +57,19 @@ class InternalServerHttp2EventHandlerFac
private final HttpProcessor httpProcessor;
private final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory;
- private final Charset charset;
+ private final CharCodingConfig charCodingConfig;
private final H2Config h2Config;
private final SSLContext sslContext;
public InternalServerHttp2EventHandlerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
- final Charset charset,
+ final CharCodingConfig charCodingConfig,
final H2Config h2Config,
final SSLContext sslContext) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
- this.charset = charset;
+ this.charCodingConfig = charCodingConfig;
this.h2Config = h2Config;
this.sslContext = sslContext;
}
@@ -82,7 +82,7 @@ class InternalServerHttp2EventHandlerFac
}
final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
return new LoggingIOEventHandler(new ServerHttpProtocolNegotiator(
- ioSession, httpProcessor, exchangeHandlerFactory, charset, h2Config,
+ ioSession, httpProcessor, exchangeHandlerFactory, charCodingConfig, h2Config,
new ConnectionListener() {
@Override
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java Thu Feb 2 19:43:52 2017
@@ -74,7 +74,7 @@ import org.apache.hc.core5.http.HttpStat
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.MalformedChunkCodingException;
import org.apache.hc.core5.http.Message;
-import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
import org.apache.hc.core5.http.impl.ConnectionListener;
@@ -972,7 +972,7 @@ public class Http1IntegrationTest extend
});
final InetSocketAddress serverEndpoint = server.start();
- client.start(H1Config.DEFAULT, ConnectionConfig.custom().setBufferSize(256).build());
+ client.start(H1Config.custom().setBufferSize(256).build());
final Future<ClientEndpoint> connectFuture = client.connect(
"localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
@@ -1138,7 +1138,7 @@ public class Http1IntegrationTest extend
});
final InetSocketAddress serverEndpoint = server.start();
- client.start(H1Config.DEFAULT, ConnectionConfig.custom().setBufferSize(256).build());
+ client.start(H1Config.custom().setBufferSize(256).build());
final Future<ClientEndpoint> connectFuture = client.connect(
"localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
@@ -1350,7 +1350,7 @@ public class Http1IntegrationTest extend
},
H1Config.DEFAULT,
- ConnectionConfig.DEFAULT,
+ CharCodingConfig.DEFAULT,
DefaultConnectionReuseStrategy.INSTANCE,
scheme == ProtocolScheme.HTTPS ? createServerSSLContext() : null) {
@@ -1360,7 +1360,7 @@ public class Http1IntegrationTest extend
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
final H1Config h1Config,
- final ConnectionConfig connectionConfig,
+ final CharCodingConfig connectionConfig,
final ConnectionReuseStrategy connectionReuseStrategy,
final NHttpMessageParser<HttpRequest> incomingMessageParser,
final NHttpMessageWriter<HttpResponse> outgoingMessageWriter,
@@ -1520,8 +1520,7 @@ public class Http1IntegrationTest extend
});
final InetSocketAddress serverEndpoint = server.start();
- client.start(new DefaultHttpProcessor(new RequestContent(), new RequestConnControl()),
- H1Config.DEFAULT, ConnectionConfig.DEFAULT);
+ client.start(new DefaultHttpProcessor(new RequestContent(), new RequestConnControl()), H1Config.DEFAULT);
final Future<ClientEndpoint> connectFuture = client.connect(
"localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
Copied: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/CharCodingConfig.java (from r1781462, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/CharCodingConfig.java?p2=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/CharCodingConfig.java&p1=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java&r1=1781462&r2=1781463&rev=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/CharCodingConfig.java Thu Feb 2 19:43:52 2017
@@ -41,31 +41,24 @@ import org.apache.hc.core5.util.Args;
* @since 4.3
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
-public class ConnectionConfig {
+public class CharCodingConfig {
- public static final ConnectionConfig DEFAULT = new Builder().build();
+ public static final CharCodingConfig DEFAULT = new Builder().build();
- private final int bufferSize;
private final Charset charset;
private final CodingErrorAction malformedInputAction;
private final CodingErrorAction unmappableInputAction;
- ConnectionConfig(
- final int bufferSize,
+ CharCodingConfig(
final Charset charset,
final CodingErrorAction malformedInputAction,
final CodingErrorAction unmappableInputAction) {
super();
- this.bufferSize = bufferSize;
this.charset = charset;
this.malformedInputAction = malformedInputAction;
this.unmappableInputAction = unmappableInputAction;
}
- public int getBufferSize() {
- return bufferSize;
- }
-
public Charset getCharset() {
return charset;
}
@@ -81,22 +74,20 @@ public class ConnectionConfig {
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
- builder.append("[bufferSize=").append(this.bufferSize)
- .append(", charset=").append(this.charset)
+ builder.append("[charset=").append(this.charset)
.append(", malformedInputAction=").append(this.malformedInputAction)
.append(", unmappableInputAction=").append(this.unmappableInputAction)
.append("]");
return builder.toString();
}
- public static ConnectionConfig.Builder custom() {
+ public static CharCodingConfig.Builder custom() {
return new Builder();
}
- public static ConnectionConfig.Builder copy(final ConnectionConfig config) {
- Args.notNull(config, "Connection config");
+ public static CharCodingConfig.Builder copy(final CharCodingConfig config) {
+ Args.notNull(config, "Config");
return new Builder()
- .setBufferSize(config.getBufferSize())
.setCharset(config.getCharset())
.setMalformedInputAction(config.getMalformedInputAction())
.setUnmappableInputAction(config.getUnmappableInputAction());
@@ -104,24 +95,11 @@ public class ConnectionConfig {
public static class Builder {
- private int bufferSize;
- private int fragmentSizeHint;
private Charset charset;
private CodingErrorAction malformedInputAction;
private CodingErrorAction unmappableInputAction;
Builder() {
- this.fragmentSizeHint = -1;
- }
-
- public Builder setBufferSize(final int bufferSize) {
- this.bufferSize = bufferSize;
- return this;
- }
-
- public Builder setFragmentSizeHint(final int fragmentSizeHint) {
- this.fragmentSizeHint = fragmentSizeHint;
- return this;
}
public Builder setCharset(final Charset charset) {
@@ -145,17 +123,12 @@ public class ConnectionConfig {
return this;
}
- public ConnectionConfig build() {
- Charset cs = charset;
- if (cs == null && (malformedInputAction != null || unmappableInputAction != null)) {
- cs = StandardCharsets.US_ASCII;
+ public CharCodingConfig build() {
+ Charset charsetCopy = charset;
+ if (charsetCopy == null && (malformedInputAction != null || unmappableInputAction != null)) {
+ charsetCopy = StandardCharsets.US_ASCII;
}
- final int bufSize = this.bufferSize > 0 ? this.bufferSize : 8 * 1024;
- return new ConnectionConfig(
- bufSize,
- cs,
- malformedInputAction,
- unmappableInputAction);
+ return new CharCodingConfig(charsetCopy, malformedInputAction, unmappableInputAction);
}
}
Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/CharCodingConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/CharCodingConfig.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/CharCodingConfig.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java?rev=1781463&r1=1781462&r2=1781463&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java Thu Feb 2 19:43:52 2017
@@ -43,15 +43,17 @@ public class H1Config {
public static final H1Config DEFAULT = new Builder().build();
+ private final int bufferSize;
private final int chunkSizeHint;
private final int waitForContinueTimeout;
private final int maxLineLength;
private final int maxHeaderCount;
private final int maxEmptyLineCount;
- H1Config(final int chunkSizeHint, final int waitForContinueTimeout, final int maxLineLength,
- final int maxHeaderCount, final int maxEmptyLineCount) {
+ H1Config(final int bufferSize, final int chunkSizeHint, final int waitForContinueTimeout,
+ final int maxLineLength, final int maxHeaderCount, final int maxEmptyLineCount) {
super();
+ this.bufferSize = bufferSize;
this.chunkSizeHint = chunkSizeHint;
this.waitForContinueTimeout = waitForContinueTimeout;
this.maxLineLength = maxLineLength;
@@ -59,6 +61,10 @@ public class H1Config {
this.maxEmptyLineCount = maxEmptyLineCount;
}
+ public int getBufferSize() {
+ return bufferSize;
+ }
+
public int getChunkSizeHint() {
return chunkSizeHint;
}
@@ -75,9 +81,6 @@ public class H1Config {
return maxHeaderCount;
}
- /**
- * @since 5.0
- */
public int getMaxEmptyLineCount() {
return this.maxEmptyLineCount;
}
@@ -85,7 +88,8 @@ public class H1Config {
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
- builder.append("[chunkSizeHint=").append(chunkSizeHint)
+ builder.append("[bufferSize=").append(bufferSize)
+ .append(", chunkSizeHint=").append(chunkSizeHint)
.append(", waitForContinueTimeout=").append(waitForContinueTimeout)
.append(", maxLineLength=").append(maxLineLength)
.append(", maxHeaderCount=").append(maxHeaderCount)
@@ -99,8 +103,9 @@ public class H1Config {
}
public static H1Config.Builder copy(final H1Config config) {
- Args.notNull(config, "Message constraints");
+ Args.notNull(config, "Config");
return new Builder()
+ .setBufferSize(config.getBufferSize())
.setChunkSizeHint(config.getChunkSizeHint())
.setWaitForContinueTimeout(config.getWaitForContinueTimeout())
.setMaxHeaderCount(config.getMaxHeaderCount())
@@ -110,6 +115,7 @@ public class H1Config {
public static class Builder {
+ private int bufferSize;
private int chunkSizeHint;
private int waitForContinueTimeout;
private int maxLineLength;
@@ -117,6 +123,7 @@ public class H1Config {
private int maxEmptyLineCount;
Builder() {
+ this.bufferSize = -1;
this.chunkSizeHint = -1;
this.waitForContinueTimeout = 3000;
this.maxLineLength = -1;
@@ -124,6 +131,11 @@ public class H1Config {
this.maxEmptyLineCount = 10;
}
+ public Builder setBufferSize(final int bufferSize) {
+ this.bufferSize = bufferSize;
+ return this;
+ }
+
public Builder setChunkSizeHint(final int chunkSizeHint) {
this.chunkSizeHint = chunkSizeHint;
return this;
@@ -150,7 +162,7 @@ public class H1Config {
}
public H1Config build() {
- return new H1Config(chunkSizeHint, waitForContinueTimeout, maxLineLength, maxHeaderCount, maxEmptyLineCount);
+ return new H1Config(bufferSize > 0 ? bufferSize : 8192, chunkSizeHint, waitForContinueTimeout, maxLineLength, maxHeaderCount, maxEmptyLineCount);
}
}