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 2012/09/27 12:08:44 UTC

svn commit: r1390920 - in /httpcomponents/httpcore/trunk/httpcore/src: main/java/org/apache/http/impl/ test/java/org/apache/http/integration/ test/java/org/apache/http/testserver/

Author: olegk
Date: Thu Sep 27 10:08:43 2012
New Revision: 1390920

URL: http://svn.apache.org/viewvc?rev=1390920&view=rev
Log:
Added wire / header logging to the integration tests in the base module; fixed regression in BHttpConnectionBase#awaitInput causing test case failure

Added:
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java   (with props)
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java   (with props)
Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingInputStream.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java?rev=1390920&r1=1390919&r2=1390920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java Thu Sep 27 10:08:43 2012
@@ -153,6 +153,14 @@ public class BHttpConnectionBase impleme
         Asserts.check(this.open, "Connection is not open");
     }
 
+    protected InputStream getSocketInputStream(final Socket socket) throws IOException {
+        return socket.getInputStream();
+    }
+
+    protected OutputStream getSocketOutputStream(final Socket socket) throws IOException {
+        return socket.getOutputStream();
+    }
+
     /**
      * Binds this connection to the given {@link Socket}. This socket will be
      * used by the connection to send and receive data.
@@ -167,8 +175,8 @@ public class BHttpConnectionBase impleme
         Args.notNull(socket, "Socket");
         this.socket = socket;
         this.open = true;
-        this.inbuffer.bind(socket.getInputStream());
-        this.outbuffer.bind(socket.getOutputStream());
+        this.inbuffer.bind(getSocketInputStream(socket));
+        this.outbuffer.bind(getSocketOutputStream(socket));
     }
 
     protected SessionInputBuffer getSessionInputBuffer() {
@@ -364,9 +372,9 @@ public class BHttpConnectionBase impleme
         }
         int oldtimeout = this.socket.getSoTimeout();
         try {
-            this.socket.setSoTimeout(1);
-            int i = this.inbuffer.fillBuffer();
-            return i != -1;
+            this.socket.setSoTimeout(timeout);
+            this.inbuffer.fillBuffer();
+            return this.inbuffer.hasBufferedData();
         } finally {
             this.socket.setSoTimeout(oldtimeout);
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java?rev=1390920&r1=1390919&r2=1390920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java Thu Sep 27 10:08:43 2012
@@ -134,6 +134,12 @@ public class DefaultBHttpClientConnectio
         return new DefaultHttpRequestWriter(buffer, lineFormatter);
     }
 
+    protected void onResponseReceived(final HttpResponse response) {
+    }
+
+    protected void onRequestSubmitted(final HttpRequest request) {
+    }
+
     @Override
     public void bind(final Socket socket) throws IOException {
         super.bind(socket);
@@ -153,6 +159,7 @@ public class DefaultBHttpClientConnectio
         Args.notNull(request, "HTTP request");
         assertOpen();
         this.requestWriter.write(request);
+        onRequestSubmitted(request);
         incrementRequestCount();
     }
 
@@ -172,6 +179,7 @@ public class DefaultBHttpClientConnectio
     public HttpResponse receiveResponseHeader() throws HttpException, IOException {
         assertOpen();
         HttpResponse response = this.responseParser.parse();
+        onResponseReceived(response);
         if (response.getStatusLine().getStatusCode() >= 200) {
             incrementResponseCount();
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java?rev=1390920&r1=1390919&r2=1390920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java Thu Sep 27 10:08:43 2012
@@ -141,6 +141,12 @@ public class DefaultBHttpServerConnectio
         return new DefaultHttpResponseWriter(buffer, lineFormatter);
     }
 
+    protected void onRequestReceived(final HttpRequest request) {
+    }
+
+    protected void onResponseSubmitted(final HttpResponse response) {
+    }
+
     @Override
     public void bind(final Socket socket) throws IOException {
         super.bind(socket);
@@ -150,6 +156,7 @@ public class DefaultBHttpServerConnectio
             throws HttpException, IOException {
         assertOpen();
         HttpRequest request = this.requestParser.parse();
+        onRequestReceived(request);
         incrementRequestCount();
         return request;
     }
@@ -167,6 +174,7 @@ public class DefaultBHttpServerConnectio
         Args.notNull(response, "HTTP response");
         assertOpen();
         this.responseWriter.write(response);
+        onResponseSubmitted(response);
         if (response.getStatusLine().getStatusCode() >= 200) {
             incrementResponseCount();
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java?rev=1390920&r1=1390919&r2=1390920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java Thu Sep 27 10:08:43 2012
@@ -139,7 +139,7 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -219,7 +219,7 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -302,7 +302,7 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -388,7 +388,7 @@ public class TestSyncHttp {
         this.client.getParams().setParameter(
                 CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -475,7 +475,7 @@ public class TestSyncHttp {
         // Activate 'expect: continue' handshake
         this.client.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -569,7 +569,7 @@ public class TestSyncHttp {
         // Activate 'expect: continue' handshake
         this.client.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -582,7 +582,7 @@ public class TestSyncHttp {
                 BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
                 post.addHeader("Secret", Integer.toString(r));
                 ByteArrayEntity outgoing = new ByteArrayEntity(
-                        EncodingUtils.getAsciiBytes("No content"));
+                        EncodingUtils.getAsciiBytes("No content " + r));
                 post.setEntity(outgoing);
 
                 HttpResponse response = this.client.execute(post, host, conn);
@@ -727,7 +727,7 @@ public class TestSyncHttp {
         });
 
         this.server.start();
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -799,7 +799,7 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -845,7 +845,7 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -898,7 +898,7 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {
@@ -953,7 +953,7 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(this.client.getParams());
+        DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
         try {

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java?rev=1390920&r1=1390919&r2=1390920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java Thu Sep 27 10:08:43 2012
@@ -37,6 +37,7 @@ import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
+import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.CoreConnectionPNames;
@@ -92,6 +93,10 @@ public class HttpClient {
         return this.params;
     }
 
+    public DefaultBHttpClientConnection createConnection() {
+        return new LoggingBHttpClientConnection(this.params);
+    }
+
     public HttpResponse execute(
             final HttpRequest request,
             final HttpHost targetHost,

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java?rev=1390920&r1=1390919&r2=1390920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java Thu Sep 27 10:08:43 2012
@@ -39,7 +39,6 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.HttpServerConnection;
-import org.apache.http.impl.DefaultBHttpServerConnection;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.params.BasicHttpParams;
@@ -107,7 +106,7 @@ public class HttpServer {
 
     private HttpServerConnection acceptConnection() throws IOException {
         Socket socket = this.serversocket.accept();
-        DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(this.params);
+        LoggingBHttpServerConnection conn = new LoggingBHttpServerConnection(this.params);
         conn.bind(socket);
         return conn;
     }

Added: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java?rev=1390920&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java (added)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java Thu Sep 27 10:08:43 2012
@@ -0,0 +1,117 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.testserver;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.Header;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.impl.DefaultBHttpClientConnection;
+import org.apache.http.params.HttpParams;
+
+public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection {
+
+    private static final AtomicLong COUNT = new AtomicLong();
+
+    private final String id;
+    private final Log log;
+    private final Log headerlog;
+    private final Wire wire;
+
+    public LoggingBHttpClientConnection(final HttpParams params) {
+        super(params);
+        this.id = "http-outgoing-" + COUNT.incrementAndGet();
+        this.log = LogFactory.getLog(getClass());
+        this.headerlog = LogFactory.getLog("org.apache.http.headers");
+        this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug(this.id + ": Close connection");
+        }
+        super.close();
+    }
+
+    @Override
+    public void shutdown() throws IOException {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug(this.id + ": Shutdown connection");
+        }
+        super.shutdown();
+    }
+
+    @Override
+    protected InputStream getSocketInputStream(final Socket socket) throws IOException {
+        InputStream in = super.getSocketInputStream(socket);
+        if (wire.isEnabled()) {
+            in = new LoggingInputStream(in, wire);
+        }
+        return in;
+    }
+
+    @Override
+    protected OutputStream getSocketOutputStream(final Socket socket) throws IOException {
+        OutputStream out = super.getSocketOutputStream(socket);
+        if (wire.isEnabled()) {
+            out = new LoggingOutputStream(out, wire);
+        }
+        return out;
+    }
+
+    @Override
+    protected void onResponseReceived(final HttpResponse response) {
+        if (response != null && this.headerlog.isDebugEnabled()) {
+            this.headerlog.debug(this.id + " << " + response.getStatusLine().toString());
+            Header[] headers = response.getAllHeaders();
+            for (int i = 0; i < headers.length; i++) {
+                this.headerlog.debug(this.id + " << " + headers[i].toString());
+            }
+        }
+    }
+
+    @Override
+    protected void onRequestSubmitted(final HttpRequest request) {
+        if (request != null && this.headerlog.isDebugEnabled()) {
+            this.headerlog.debug(id + " >> " + request.getRequestLine().toString());
+            Header[] headers = request.getAllHeaders();
+            for (int i = 0; i < headers.length; i++) {
+                this.headerlog.debug(this.id + " >> " + headers[i].toString());
+            }
+        }
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java?rev=1390920&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java (added)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java Thu Sep 27 10:08:43 2012
@@ -0,0 +1,117 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.testserver;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.Header;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.impl.DefaultBHttpServerConnection;
+import org.apache.http.params.HttpParams;
+
+public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection {
+
+    private static final AtomicLong COUNT = new AtomicLong();
+
+    private final String id;
+    private final Log log;
+    private final Log headerlog;
+    private final Wire wire;
+
+    public LoggingBHttpServerConnection(final HttpParams params) {
+        super(params);
+        this.id = "http-incoming-" + COUNT.incrementAndGet();
+        this.log = LogFactory.getLog(getClass());
+        this.headerlog = LogFactory.getLog("org.apache.http.headers");
+        this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug(this.id + ": Close connection");
+        }
+        super.close();
+    }
+
+    @Override
+    public void shutdown() throws IOException {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug(this.id + ": Shutdown connection");
+        }
+        super.shutdown();
+    }
+
+    @Override
+    protected InputStream getSocketInputStream(final Socket socket) throws IOException {
+        InputStream in = super.getSocketInputStream(socket);
+        if (wire.isEnabled()) {
+            in = new LoggingInputStream(in, wire);
+        }
+        return in;
+    }
+
+    @Override
+    protected OutputStream getSocketOutputStream(final Socket socket) throws IOException {
+        OutputStream out = super.getSocketOutputStream(socket);
+        if (wire.isEnabled()) {
+            out = new LoggingOutputStream(out, wire);
+        }
+        return out;
+    }
+
+    @Override
+    protected void onRequestReceived(final HttpRequest request) {
+        if (request != null && this.headerlog.isDebugEnabled()) {
+            this.headerlog.debug(this.id + " >> " + request.getRequestLine().toString());
+            Header[] headers = request.getAllHeaders();
+            for (int i = 0; i < headers.length; i++) {
+                this.headerlog.debug(this.id + " >> " + headers[i].toString());
+            }
+        }
+    }
+
+    @Override
+    protected void onResponseSubmitted(final HttpResponse response) {
+        if (response != null && this.headerlog.isDebugEnabled()) {
+            this.headerlog.debug(this.id + " << " + response.getStatusLine().toString());
+            Header[] headers = response.getAllHeaders();
+            for (int i = 0; i < headers.length; i++) {
+                this.headerlog.debug(this.id + " << " + headers[i].toString());
+            }
+        }
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingInputStream.java?rev=1390920&r1=1390919&r2=1390920&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/LoggingInputStream.java Thu Sep 27 10:08:43 2012
@@ -61,7 +61,7 @@ class LoggingInputStream extends InputSt
 
     @Override
     public int read(byte[] b, int off, int len) throws IOException {
-        int bytesRead = in.read(b);
+        int bytesRead = in.read(b, off, len);
         if (bytesRead != -1) {
             wire.input(b, off, bytesRead);
         }