hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [03/10] httpcomponents-core git commit: Fixed duplicate header logging by the classic test server and client
Date Wed, 09 Aug 2017 18:15:12 GMT
Fixed duplicate header logging by the classic test server and client


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/e7a4c2a7
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/e7a4c2a7
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/e7a4c2a7

Branch: refs/heads/master
Commit: e7a4c2a708d7fa6e5ce6e7c6c0dbe36e48760545
Parents: 80feb0f
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Wed Aug 9 11:50:50 2017 +0200
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Wed Aug 9 14:53:06 2017 +0200

----------------------------------------------------------------------
 .../testing/classic/ClassicTestClient.java      |  2 +-
 .../testing/classic/ClassicTestServer.java      |  2 +-
 .../classic/LoggingHttp1StreamListener.java     | 36 +-------------------
 .../InternalClientHttp1EventHandlerFactory.java |  2 +-
 .../InternalClientHttp2EventHandlerFactory.java |  2 +-
 .../InternalServerHttp1EventHandlerFactory.java |  2 +-
 .../InternalServerHttp2EventHandlerFactory.java |  2 +-
 .../classic/ClassicServerAndRequesterTest.java  |  4 +--
 .../nio/Http1ServerAndRequesterTest.java        |  4 +--
 .../nio/Http2ProtocolNegotiationTest.java       |  6 ++--
 .../nio/Http2ServerAndRequesterTest.java        |  4 +--
 .../http/impl/bootstrap/RequesterBootstrap.java |  2 +-
 12 files changed, 17 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
index aea5b1f..0ed3c48 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
@@ -84,7 +84,7 @@ public class ClassicTestClient {
             final HttpRequestExecutor requestExecutor = new HttpRequestExecutor(
                     HttpRequestExecutor.DEFAULT_WAIT_FOR_CONTINUE,
                     DefaultConnectionReuseStrategy.INSTANCE,
-                    LoggingHttp1StreamListener.INSTANCE_CLIENT);
+                    LoggingHttp1StreamListener.INSTANCE);
             final StrictConnPool<HttpHost, HttpClientConnection> connPool = new StrictConnPool<>(
                     20,
                     50,

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
index 41bb3f8..198cd9a 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
@@ -109,7 +109,7 @@ public class ClassicTestServer {
                     httpProcessor != null ? httpProcessor : HttpProcessors.server(),
                     handlerDecorator != null ? handlerDecorator.decorate(handler) : new BasicHttpServerExpectationDecorator(handler),
                     DefaultConnectionReuseStrategy.INSTANCE,
-                    LoggingHttp1StreamListener.INSTANCE_CLIENT);
+                    LoggingHttp1StreamListener.INSTANCE);
             final HttpServer server = new HttpServer(
                     0,
                     httpService,

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingHttp1StreamListener.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingHttp1StreamListener.java
b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingHttp1StreamListener.java
index ea513f1..ea677f3 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingHttp1StreamListener.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingHttp1StreamListener.java
@@ -27,59 +27,25 @@
 
 package org.apache.hc.core5.testing.classic;
 
-import java.util.Iterator;
-
-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.impl.Http1StreamListener;
-import org.apache.hc.core5.http.message.RequestLine;
-import org.apache.hc.core5.http.message.StatusLine;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
 public class LoggingHttp1StreamListener implements Http1StreamListener {
 
-    enum Type { CLIENT, SERVER }
-
-    public final static LoggingHttp1StreamListener INSTANCE_CLIENT = new LoggingHttp1StreamListener(Type.CLIENT);
-    public final static LoggingHttp1StreamListener INSTANCE_SERVER = new LoggingHttp1StreamListener(Type.SERVER);
+    public static final LoggingHttp1StreamListener INSTANCE = new LoggingHttp1StreamListener();
 
-    private final Type type;
     private final Logger connLog = LogManager.getLogger("org.apache.hc.core5.http.connection");
-    private final Logger headerLog = LogManager.getLogger("org.apache.hc.core5.http.headers");
-
-    private LoggingHttp1StreamListener(final Type type) {
-        this.type = type;
-    }
-
-    private String requestDirection() {
-        return type == Type.CLIENT ? " >> " : " << ";
-    }
-
-    private String responseDirection() {
-        return type == Type.CLIENT ? " << " : " >> ";
-    }
 
     @Override
     public void onRequestHead(final HttpConnection connection, final HttpRequest request)
{
-        if (headerLog.isDebugEnabled()) {
-            headerLog.debug(LoggingSupport.getId(connection) + requestDirection() + new RequestLine(request));
-            for (final Iterator<Header> it = request.headerIterator(); it.hasNext();
) {
-                headerLog.debug(LoggingSupport.getId(connection) + requestDirection() + it.next());
-            }
-        }
     }
 
     @Override
     public void onResponseHead(final HttpConnection connection, final HttpResponse response)
{
-        if (headerLog.isDebugEnabled()) {
-            headerLog.debug(LoggingSupport.getId(connection) + responseDirection() + new
StatusLine(response));
-            for (final Iterator<Header> it = response.headerIterator(); it.hasNext();
) {
-                headerLog.debug(LoggingSupport.getId(connection) + responseDirection() +
it.next());
-            }
-        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp1EventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp1EventHandlerFactory.java
b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp1EventHandlerFactory.java
index 4ebc9fe..36b45ff 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp1EventHandlerFactory.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp1EventHandlerFactory.java
@@ -116,7 +116,7 @@ class InternalClientHttp1EventHandlerFactory implements IOEventHandlerFactory
{
                 requestWriterFactory.create(),
                 DefaultContentLengthStrategy.INSTANCE,
                 DefaultContentLengthStrategy.INSTANCE,
-                LoggingHttp1StreamListener.INSTANCE_CLIENT);
+                LoggingHttp1StreamListener.INSTANCE);
         return new ClientHttp1IOEventHandler(streamDuplexer);
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp2EventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp2EventHandlerFactory.java
b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp2EventHandlerFactory.java
index 9335f7c..c19387a 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp2EventHandlerFactory.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalClientHttp2EventHandlerFactory.java
@@ -83,7 +83,7 @@ class InternalClientHttp2EventHandlerFactory implements IOEventHandlerFactory
{
                 httpProcessor != null ? httpProcessor : HttpProcessors.client(),
                 h1Config,
                 charCodingConfig,
-                LoggingHttp1StreamListener.INSTANCE_CLIENT);
+                LoggingHttp1StreamListener.INSTANCE);
         final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory(
                 httpProcessor != null ? httpProcessor : Http2Processors.client(),
                 exchangeHandlerFactory,

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp1EventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp1EventHandlerFactory.java
b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp1EventHandlerFactory.java
index 8bf8504..7273231 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp1EventHandlerFactory.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp1EventHandlerFactory.java
@@ -125,7 +125,7 @@ class InternalServerHttp1EventHandlerFactory implements IOEventHandlerFactory
{
                 responseWriterFactory.create(),
                 DefaultContentLengthStrategy.INSTANCE,
                 DefaultContentLengthStrategy.INSTANCE,
-                LoggingHttp1StreamListener.INSTANCE_SERVER);
+                LoggingHttp1StreamListener.INSTANCE);
         return new ServerHttp1IOEventHandler(streamDuplexer);
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp2EventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp2EventHandlerFactory.java
b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp2EventHandlerFactory.java
index 6d0d925..1969912 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp2EventHandlerFactory.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/InternalServerHttp2EventHandlerFactory.java
@@ -84,7 +84,7 @@ class InternalServerHttp2EventHandlerFactory implements IOEventHandlerFactory
{
                 exchangeHandlerFactory,
                 h1Config,
                 charCodingConfig,
-                LoggingHttp1StreamListener.INSTANCE_SERVER);
+                LoggingHttp1StreamListener.INSTANCE);
         final ServerHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ServerHttp2StreamMultiplexerFactory(
                 httpProcessor != null ? httpProcessor : Http2Processors.server(),
                 exchangeHandlerFactory,

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
index 1ce336c..f4d0e4d 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
@@ -89,7 +89,7 @@ public class ClassicServerAndRequesterTest {
                         }
                     })
                     .setExceptionListener(LoggingExceptionListener.INSTANCE)
-                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE_SERVER)
+                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE)
                     .create();
         }
 
@@ -120,7 +120,7 @@ public class ClassicServerAndRequesterTest {
                             .build())
                     .setMaxTotal(2)
                     .setDefaultMaxPerRoute(2)
-                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE_CLIENT)
+                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE)
                     .setConnPoolListener(LoggingConnPoolListener.INSTANCE)
                     .create();
         }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
index 96a975c..34822a2 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
@@ -142,7 +142,7 @@ public class Http1ServerAndRequesterTest {
 
                     })
                     .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
-                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE_SERVER)
+                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE)
                     .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
                     .create();
         }
@@ -181,7 +181,7 @@ public class Http1ServerAndRequesterTest {
                             .setSoTimeout(TIMEOUT)
                             .build())
                     .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
-                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE_CLIENT)
+                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE)
                     .setConnPoolListener(LoggingConnPoolListener.INSTANCE)
                     .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
                     .create();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
index 98c2c29..a652875 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
@@ -58,8 +58,8 @@ import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.ExceptionEvent;
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.reactor.ListenerEndpoint;
-import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
 import org.apache.hc.core5.testing.SSLTestContexts;
+import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
 import org.apache.hc.core5.testing.classic.LoggingHttp1StreamListener;
 import org.apache.hc.core5.util.Timeout;
 import org.apache.logging.log4j.LogManager;
@@ -111,7 +111,7 @@ public class Http2ProtocolNegotiationTest {
                     })
                     .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
                     .setStreamListener(LoggingHttp2StreamListener.INSTANCE)
-                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE_SERVER)
+                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE)
                     .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
                     .create();
         }
@@ -153,7 +153,7 @@ public class Http2ProtocolNegotiationTest {
                             .build())
                     .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
                     .setStreamListener(LoggingHttp2StreamListener.INSTANCE)
-                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE_CLIENT)
+                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE)
                     .setConnPoolListener(LoggingConnPoolListener.INSTANCE)
                     .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
                     .create();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ServerAndRequesterTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ServerAndRequesterTest.java
b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ServerAndRequesterTest.java
index f7d3a76..6f3c19a 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ServerAndRequesterTest.java
@@ -107,7 +107,7 @@ public class Http2ServerAndRequesterTest {
                                     .setSoTimeout(TIMEOUT)
                                     .build())
                     .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
-                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE_SERVER)
+                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE)
                     .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
                     .register("*", new Supplier<AsyncServerExchangeHandler>() {
 
@@ -155,7 +155,7 @@ public class Http2ServerAndRequesterTest {
                             .setSoTimeout(TIMEOUT)
                             .build())
                     .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
-                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE_CLIENT)
+                    .setStreamListener(LoggingHttp1StreamListener.INSTANCE)
                     .setConnPoolListener(LoggingConnPoolListener.INSTANCE)
                     .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
                     .create();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e7a4c2a7/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/RequesterBootstrap.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/RequesterBootstrap.java
b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/RequesterBootstrap.java
index 4110d0e..b5c45fe 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/RequesterBootstrap.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/RequesterBootstrap.java
@@ -94,7 +94,7 @@ public class RequesterBootstrap {
         return this;
     }
 
-    public final RequesterBootstrap setConnectFactory(final HttpConnectionFactory<? extends
HttpClientConnection> connectFactory) {
+    public final RequesterBootstrap setConnectionFactory(final HttpConnectionFactory<?
extends HttpClientConnection> connectFactory) {
         this.connectFactory = connectFactory;
         return this;
     }


Mime
View raw message