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/05/09 20:03:30 UTC

[01/35] httpcomponents-core git commit: 4.1.x branch

Repository: httpcomponents-core
Updated Branches:
  refs/heads/4.1.x [created] 9d0d6115c


4.1.x branch


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1100593 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 391cc9d8f03ba095e4d6970a1c3cf96af4a8cfc3
Parents: dfc63f8
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat May 7 19:02:58 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat May 7 19:02:58 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  3 +
 .../http/impl/nio/NHttpConnectionBase.java      | 11 ----
 .../http/impl/nio/reactor/SSLIOSession.java     |  8 ---
 .../http/nio/entity/ContentInputStream.java     |  2 +-
 .../apache/http/nio/entity/ContentListener.java |  2 +-
 .../http/nio/entity/ContentOutputStream.java    |  2 +-
 .../http/nio/entity/SkipContentListener.java    |  2 +-
 .../http/nio/protocol/NHttpHandlerBase.java     |  2 +-
 .../nio/protocol/SimpleNHttpRequestHandler.java |  2 +-
 .../http/SimpleIOReactorExceptionHandler.java   |  2 +-
 .../nio/protocol/RequestExecutionHandler.java   |  2 +-
 .../http/nio/protocol/RequestHandler.java       |  2 +-
 .../src/main/java/org/apache/http/Header.java   |  6 +-
 .../main/java/org/apache/http/HttpHeaders.java  |  2 +-
 .../org/apache/http/entity/BasicHttpEntity.java |  2 +-
 .../apache/http/entity/InputStreamEntity.java   | 36 ++++++-----
 .../org/apache/http/entity/StringEntity.java    | 12 ++--
 .../org/apache/http/message/BasicHeader.java    |  2 +-
 .../message/BasicHeaderElementIterator.java     |  2 +-
 .../apache/http/params/AbstractHttpParams.java  | 17 +-----
 .../org/apache/http/params/BasicHttpParams.java | 23 +------
 .../apache/http/params/DefaultedHttpParams.java | 63 +-------------------
 .../java/org/apache/http/params/HttpParams.java |  2 +-
 .../org/apache/http/params/HttpParamsNames.java | 54 -----------------
 .../java/org/apache/http/util/LangUtils.java    |  2 +-
 .../apache/http/message/TestHeaderGroup.java    |  2 +-
 .../apache/http/params/TestBasicHttpParams.java | 18 ------
 .../http/params/TestDefaultedHttpParams.java    | 41 -------------
 28 files changed, 52 insertions(+), 272 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 7546aed..6904f1b 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,5 +1,8 @@
 Changes since 4.1
 
+* [HTTPCORE-255]: Fixed resource management in InputStreamEntity#writeTo()
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-254]: Erratic results from metrics (sebb)
 
 * [HTTPCORE-242]: Fixed NPE in AsyncNHttpClientHandler caused by an early response to an

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index 4307afc..1cfd500 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -160,17 +160,6 @@ public class NHttpConnectionBase
     }
 
     /**
-     * @since 4.1.1
-     */
-    protected void bind(final IOSession session) {
-        if (session == null) {
-            throw new IllegalArgumentException("I/O session may not be null");
-        }
-        this.session.setBufferStatus(null);
-        setSession(session);
-    }
-
-    /**
      * @since 4.1
      */
     protected HttpTransportMetricsImpl createTransportMetrics() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
index cd2f42b..bfed421 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
@@ -35,7 +35,6 @@ import org.apache.http.params.HttpParams;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLEngineResult.HandshakeStatus;
 import javax.net.ssl.SSLEngineResult.Status;
 import javax.net.ssl.SSLException;
@@ -143,13 +142,6 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
         doHandshake();
     }
 
-    /**
-     * @since 4.1.1
-     */
-    public synchronized SSLSession getSSLSession() {
-        return this.sslEngine.getSession();
-    }
-    
     private void doHandshake() throws SSLException {
         boolean handshaking = true;
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
index c204cf5..3ae96e6 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
@@ -86,4 +86,4 @@ public class ContentInputStream extends InputStream {
         super.close();
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentListener.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentListener.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentListener.java
index 00addcf..8162df9 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentListener.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentListener.java
@@ -53,4 +53,4 @@ public interface ContentListener {
      */
     void finished();
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java
index 0ccf897..944c291 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java
@@ -76,4 +76,4 @@ public class ContentOutputStream extends OutputStream {
         this.buffer.write(b);
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
index ec97fed..06f654a 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
@@ -67,4 +67,4 @@ public class SkipContentListener implements ContentListener {
     public void finished() {
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java
index f8f8605..0880dcc 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java
@@ -137,4 +137,4 @@ public abstract class NHttpHandlerBase {
             && status != HttpStatus.SC_RESET_CONTENT;
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/main/java/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
index 28f38d2..9170ccd 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
@@ -55,4 +55,4 @@ public abstract class SimpleNHttpRequestHandler implements NHttpRequestHandler {
     public abstract void handle(HttpRequest request, HttpResponse response, HttpContext context)
         throws HttpException, IOException;
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java b/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
index 4b56921..e349be5 100644
--- a/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
+++ b/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
@@ -44,4 +44,4 @@ class SimpleIOReactorExceptionHandler implements IOReactorExceptionHandler {
         return false;
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestExecutionHandler.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestExecutionHandler.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestExecutionHandler.java
index d108da7..3aeb66a 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestExecutionHandler.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestExecutionHandler.java
@@ -100,4 +100,4 @@ abstract class RequestExecutionHandler
         }
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestHandler.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestHandler.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestHandler.java
index 865e19a..3f3f62b 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestHandler.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/RequestHandler.java
@@ -99,4 +99,4 @@ final class RequestHandler extends SimpleNHttpRequestHandler implements HttpRequ
         response.setEntity(entity);
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/Header.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/Header.java b/httpcore/src/main/java/org/apache/http/Header.java
index e8012db..6ebc7a1 100644
--- a/httpcore/src/main/java/org/apache/http/Header.java
+++ b/httpcore/src/main/java/org/apache/http/Header.java
@@ -51,21 +51,21 @@ public interface Header {
 
     /**
      * Get the name of the Header.
-     * 
+     *
      * @return the name of the Header,  never {@code null}
      */
     String getName();
 
     /**
      * Get the value of the Header.
-     * 
+     *
      * @return the value of the Header,  may be {@code null}
      */
     String getValue();
 
     /**
      * Parses the value.
-     * 
+     *
      * @return an array of {@link HeaderElement} entries, may be empty, but is never {@code null}
      * @throws ParseException
      */

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/HttpHeaders.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/HttpHeaders.java b/httpcore/src/main/java/org/apache/http/HttpHeaders.java
index 48cbd1a..f85384c 100644
--- a/httpcore/src/main/java/org/apache/http/HttpHeaders.java
+++ b/httpcore/src/main/java/org/apache/http/HttpHeaders.java
@@ -203,4 +203,4 @@ public final class HttpHeaders {
     /** RFC 1945 (HTTP/1.0) Section 10.16, RFC 2616 (HTTP/1.1) Section 14.47 */
     public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java b/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
index 8220158..85fab87 100644
--- a/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
@@ -124,7 +124,7 @@ public class BasicHttpEntity extends AbstractHttpEntity {
 
     /**
      * Closes the content InputStream.
-     * 
+     *
      * @deprecated Either use {@link #getContent()} and call {@link java.io.InputStream#close()} on that;
      * otherwise call {@link #writeTo(OutputStream)} which is required to free the resources.
      */

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java b/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
index 433fc05..43e4eb8 100644
--- a/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
@@ -70,24 +70,28 @@ public class InputStreamEntity extends AbstractHttpEntity {
             throw new IllegalArgumentException("Output stream may not be null");
         }
         InputStream instream = this.content;
-        byte[] buffer = new byte[BUFFER_SIZE];
-        int l;
-        if (this.length < 0) {
-            // consume until EOF
-            while ((l = instream.read(buffer)) != -1) {
-                outstream.write(buffer, 0, l);
-            }
-        } else {
-            // consume no more than length
-            long remaining = this.length;
-            while (remaining > 0) {
-                l = instream.read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
-                if (l == -1) {
-                    break;
+        try {
+            byte[] buffer = new byte[BUFFER_SIZE];
+            int l;
+            if (this.length < 0) {
+                // consume until EOF
+                while ((l = instream.read(buffer)) != -1) {
+                    outstream.write(buffer, 0, l);
+                }
+            } else {
+                // consume no more than length
+                long remaining = this.length;
+                while (remaining > 0) {
+                    l = instream.read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
+                    if (l == -1) {
+                        break;
+                    }
+                    outstream.write(buffer, 0, l);
+                    remaining -= l;
                 }
-                outstream.write(buffer, 0, l);
-                remaining -= l;
             }
+        } finally {
+            instream.close();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/StringEntity.java b/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
index 9bfb3d2..6aa0132 100644
--- a/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
@@ -47,11 +47,11 @@ public class StringEntity extends AbstractHttpEntity implements Cloneable {
 
     /**
      * Creates a StringEntity with the specified content, mimetype and charset
-     * 
+     *
      * @param string content to be used. Not {@code null}.
      * @param mimeType mime type to be used. May be {@code null}, in which case the default is {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain"
      * @param charset character set to be used. May be {@code null}, in which case the default is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
-     * 
+     *
      * @since 4.1
      * @throws IllegalArgumentException if the string parameter is null
      */
@@ -75,10 +75,10 @@ public class StringEntity extends AbstractHttpEntity implements Cloneable {
      * Creates a StringEntity with the specified content and charset.
      * <br/>
      * The mime type defaults to {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
-     * 
+     *
      * @param string content to be used. Not {@code null}.
      * @param charset character set to be used. May be {@code null}, in which case the default is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
-     * 
+     *
      * @throws IllegalArgumentException if the string parameter is null
      */
     public StringEntity(final String string, String charset)
@@ -92,9 +92,9 @@ public class StringEntity extends AbstractHttpEntity implements Cloneable {
      * The charset defaults to {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1".
      * <br/>
      * The mime type defaults to {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
-     * 
+     *
      * @param string content to be used. Not {@code null}.
-     * 
+     *
      * @throws IllegalArgumentException if the string parameter is null
      */
     public StringEntity(final String string)

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/message/BasicHeader.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/message/BasicHeader.java b/httpcore/src/main/java/org/apache/http/message/BasicHeader.java
index 5939351..861815f 100644
--- a/httpcore/src/main/java/org/apache/http/message/BasicHeader.java
+++ b/httpcore/src/main/java/org/apache/http/message/BasicHeader.java
@@ -41,7 +41,7 @@ import org.apache.http.ParseException;
 public class BasicHeader implements Header, Cloneable, Serializable {
 
     private static final long serialVersionUID = -5427236326487562174L;
-    
+
     private final String name;
     private final String value;
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
index b6a4336..0ee495a 100644
--- a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
+++ b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
@@ -151,4 +151,4 @@ public class BasicHeaderElementIterator implements HeaderElementIterator {
         throw new UnsupportedOperationException("Remove not supported");
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java b/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java
index 9c7584e..11c0c34 100644
--- a/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java
+++ b/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java
@@ -27,11 +27,8 @@
 
 package org.apache.http.params;
 
-import java.util.Set;
-
 import org.apache.http.params.HttpParams;
 
-
 /**
  * Abstract base class for parameter collections.
  * Type specific setters and getters are mapped to the abstract,
@@ -39,7 +36,7 @@ import org.apache.http.params.HttpParams;
  *
  * @since 4.0
  */
-public abstract class AbstractHttpParams implements HttpParams, HttpParamsNames {
+public abstract class AbstractHttpParams implements HttpParams {
 
     /**
      * Instantiates parameters.
@@ -108,16 +105,4 @@ public abstract class AbstractHttpParams implements HttpParams, HttpParamsNames
         return !getBooleanParameter(name, false);
     }
 
-    /**
-     * {@inheritDoc}
-     * <p>
-     * Dummy implementation - must be overridden by subclasses.
-     * 
-     * @since 4.1.1
-     * @throws UnsupportedOperationException - always
-     */
-    public Set getNames(){
-        throw new UnsupportedOperationException();
-    }
-
 } // class AbstractHttpParams

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java b/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
index f7a4319..c85c831 100644
--- a/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
+++ b/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
@@ -28,11 +28,9 @@
 package org.apache.http.params;
 
 import java.io.Serializable;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Set;
 
 import org.apache.http.params.HttpParams;
 
@@ -150,14 +148,7 @@ public class BasicHttpParams extends AbstractHttpParams implements Serializable,
         return clone;
     }
 
-    /**
-     * Copies the locally defined parameters to the argument parameters.
-     * This method is called from {@link #clone()}.
-     *
-     * @param target    the parameters to which to copy
-     * @since 4.1.1
-     */
-    public void copyParams(HttpParams target) {
+    private void copyParams(HttpParams target) {
         Iterator iter = parameters.entrySet().iterator();
         while (iter.hasNext()) {
             Map.Entry me = (Map.Entry) iter.next();
@@ -166,16 +157,4 @@ public class BasicHttpParams extends AbstractHttpParams implements Serializable,
         }
     }
 
-    /**
-     * Returns the current set of names.
-     * 
-     * Changes to the underlying HttpParams are not reflected
-     * in the set - it is a snapshot.
-     * 
-     * @return the names, as a Set<String>
-     * @since 4.1.1
-     */
-    public Set getNames() {
-        return new HashSet(parameters.keySet());
-    }
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java b/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java
index 316ddb4..d40652a 100644
--- a/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java
+++ b/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java
@@ -27,11 +27,6 @@
 
 package org.apache.http.params;
 
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.http.params.HttpParams;
-
 /**
  * {@link HttpParams} implementation that delegates resolution of a parameter
  * to the given default {@link HttpParams} instance if the parameter is not
@@ -47,7 +42,7 @@ public final class DefaultedHttpParams extends AbstractHttpParams {
 
     /**
      * Create the defaulted set of HttpParams.
-     * 
+     *
      * @param local the mutable set of HttpParams
      * @param defaults the default set of HttpParams, not mutated by this class
      */
@@ -100,65 +95,11 @@ public final class DefaultedHttpParams extends AbstractHttpParams {
     }
 
     /**
-     * 
+     *
      * @return the default HttpParams collection
-     * @deprecated (4.1.1) do not use, will be removed in a later version
      */
     public HttpParams getDefaults() {
         return this.defaults;
     }
 
-    /**
-     * Returns the current set of names
-     * from both the local and default HttpParams instances.
-     * 
-     * Changes to the underlying HttpParams intances are not reflected
-     * in the set - it is a snapshot.
-     * 
-     * @return the combined set of names, as a Set<String>
-     * @since 4.1.1
-     * @throws UnsupportedOperationException if either the local or default HttpParams instances do not implement HttpParamsNames
-     */
-    public Set getNames() {
-        Set combined = new HashSet(getNames(defaults));
-        combined.addAll(getNames(local));
-        return combined ;
-    }
-
-    /**
-     * Returns the current set of defaults names.
-     * 
-     * Changes to the underlying HttpParams are not reflected
-     * in the set - it is a snapshot.
-     * 
-     * @return the names, as a Set<String>
-     * @since 4.1.1
-     * @throws UnsupportedOperationException if the default HttpParams instance does not implement HttpParamsNames
-     */
-    public Set getDefaultNames() {
-        return new HashSet(getNames(defaults));
-    }
-
-    /**
-     * Returns the current set of local names.
-     * 
-     * Changes to the underlying HttpParams are not reflected
-     * in the set - it is a snapshot.
-     * 
-     * @return the names, as a Set<String>
-     * @since 4.1.1
-     * @throws UnsupportedOperationException if the local HttpParams instance does not implement HttpParamsNames
-     */
-    public Set getLocalNames() {
-        return new HashSet(getNames(local));
-    }
-
-    // Helper method
-    private Set getNames(HttpParams params) {
-        if (params instanceof HttpParamsNames) {
-            return ((HttpParamsNames) params).getNames();
-        }
-        throw new UnsupportedOperationException("HttpParams instance does not implement HttpParamsNames");
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/params/HttpParams.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/params/HttpParams.java b/httpcore/src/main/java/org/apache/http/params/HttpParams.java
index dd9da11..5aab3c7 100644
--- a/httpcore/src/main/java/org/apache/http/params/HttpParams.java
+++ b/httpcore/src/main/java/org/apache/http/params/HttpParams.java
@@ -31,7 +31,7 @@ package org.apache.http.params;
  * HttpParams interface represents a collection of immutable values that define
  * a runtime behavior of a component. HTTP parameters should be simple objects:
  * integers, doubles, strings, collections and objects that remain immutable
- * at runtime. HttpParams is expected to be used in 'write once - read many' mode. 
+ * at runtime. HttpParams is expected to be used in 'write once - read many' mode.
  * Once initialized, HTTP parameters are not expected to mutate in
  * the course of HTTP message processing.
  * <p>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/params/HttpParamsNames.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/params/HttpParamsNames.java b/httpcore/src/main/java/org/apache/http/params/HttpParamsNames.java
deleted file mode 100644
index 745095e..0000000
--- a/httpcore/src/main/java/org/apache/http/params/HttpParamsNames.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ====================================================================
- * 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.params;
-
-import java.util.Set;
-
-/**
- * Gives access to the full set of parameter names.
- *
- * @see HttpParams
- *
- * @since 4.1.1
- */
-public interface HttpParamsNames {
-
-    /**
-     * Returns the current set of names;
-     * in the case of stacked parameters, returns the names
-     * from all the participating HttpParams instances.
-     * 
-     * Changes to the underlying HttpParams are not reflected
-     * in the set - it is a snapshot.
-     * 
-     * @return the names, as a Set<String>
-     * @since 4.1.1
-     */
-    Set getNames();
-    
-}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/main/java/org/apache/http/util/LangUtils.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/util/LangUtils.java b/httpcore/src/main/java/org/apache/http/util/LangUtils.java
index 61ae775..f2f0f38 100644
--- a/httpcore/src/main/java/org/apache/http/util/LangUtils.java
+++ b/httpcore/src/main/java/org/apache/http/util/LangUtils.java
@@ -57,7 +57,7 @@ public final class LangUtils {
 
     /**
      * Check if two objects are equal.
-     * 
+     *
      * @param obj1 first object to compare, may be {@code null}
      * @param obj2 second object to compare, may be {@code null}
      * @return {@code true} if the objects are equal or both null

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java b/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
index c16a487..06085b4 100644
--- a/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
+++ b/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
@@ -204,5 +204,5 @@ public class TestHeaderGroup extends TestCase {
             assertEquals(headers1[i].getValue(), headers2[i].getValue());
         }
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java b/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java
index f341f12..a3272be 100644
--- a/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java
+++ b/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java
@@ -27,9 +27,6 @@
 
 package org.apache.http.params;
 
-import java.util.Iterator;
-import java.util.Set;
-
 import junit.framework.TestCase;
 
 /**
@@ -56,19 +53,4 @@ public class TestBasicHttpParams extends TestCase {
                 params.removeParameter("param1"));
     }
 
-    public void testgetNames() {
-        BasicHttpParams params = new BasicHttpParams();
-        Set nameSet = params.getNames();
-        assertTrue(nameSet.isEmpty());
-        params.setBooleanParameter("true", true);
-        assertTrue(nameSet.isEmpty()); // Still empty, as it is a snapshot
-        nameSet = params.getNames();
-        assertFalse(nameSet.isEmpty());
-        assertEquals(1, nameSet.size());
-        Iterator iterator = nameSet.iterator(); // refetch, as iterator is a snapshot
-        assertTrue("Iterator has an entry",iterator.hasNext());
-        String entry = (String) iterator.next();
-        // Note: Java 1.3 requires JUnit 3.8.1 which does not have assertTrue(Boolean)
-        assertTrue(((Boolean) params.getParameter(entry)).booleanValue());
-    }
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/391cc9d8/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java b/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java
index 47642bb..a57e973 100644
--- a/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java
+++ b/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java
@@ -27,8 +27,6 @@
 
 package org.apache.http.params;
 
-import java.util.Set;
-
 import junit.framework.TestCase;
 
 /**
@@ -45,14 +43,8 @@ public class TestDefaultedHttpParams extends TestCase {
         DefaultedHttpParams deflt = new DefaultedHttpParams(new BasicHttpParams(), new BasicHttpParams());
         assertFalse("The parameter should not be removed successfully", deflt.removeParameter("param1"));
         deflt.setParameter("param1", "paramValue1");
-        assertEquals(0, deflt.getDefaultNames().size());
-        assertEquals(1, deflt.getNames().size());
-        assertEquals(1, deflt.getLocalNames().size());
         assertTrue("The parameter should be removed successfully", deflt.removeParameter("param1"));
         assertFalse("The parameter should not be present", deflt.removeParameter("param1"));
-        assertEquals(0, deflt.getDefaultNames().size());
-        assertEquals(0, deflt.getNames().size());
-        assertEquals(0, deflt.getLocalNames().size());
     }
 
     public void testEmptyParams() {
@@ -60,39 +52,6 @@ public class TestDefaultedHttpParams extends TestCase {
         assertNull("The parameter should not be present", deflt.getParameter("param1"));
         //try a remove from an empty params
         assertFalse("The parameter should not be present", deflt.removeParameter("param1"));
-
-        assertEquals(0, deflt.getNames().size());
-        assertEquals(0, deflt.getLocalNames().size());
-        assertEquals(0, deflt.getDefaultNames().size());
-    }
-
-    private HttpParams addParams(String name){
-        BasicHttpParams params = new BasicHttpParams();
-        params.setParameter("common","both");
-        params.setParameter(name,"value");
-        return params;
     }
 
-    public void testgetNames() {
-        DefaultedHttpParams params = new DefaultedHttpParams(addParams("local"), addParams("default"));
-
-        Set nameSet = params.getNames();
-        assertEquals(3, nameSet.size());
-        Set localnameSet = params.getLocalNames();
-        assertEquals(2, localnameSet.size());
-        Set defaultnameSet = params.getDefaultNames();
-        assertEquals(2, defaultnameSet.size());
-        
-        params.setParameter("new", null);
-        assertEquals(3, nameSet.size()); // Name set not yet updated
-        assertEquals(2, localnameSet.size());
-        assertEquals(2, defaultnameSet.size());
-        
-        nameSet = params.getNames();
-        localnameSet = params.getLocalNames();
-        defaultnameSet = params.getDefaultNames();
-        assertEquals(4, nameSet.size());
-        assertEquals(3, localnameSet.size());
-        assertEquals(2, defaultnameSet.size());
-    }
 }


[20/35] httpcomponents-core git commit: Upgrade project version to 4.1.4-SNAPSHOT

Posted by ol...@apache.org.
Upgrade project version to 4.1.4-SNAPSHOT

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1152469 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: f4a290e4d1463a51d193b295ef9f0c23628d31cf
Parents: ff5986b
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat Jul 30 14:15:34 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Jul 30 14:15:34 2011 +0000

----------------------------------------------------------------------
 httpcore-ab/pom.xml        | 2 +-
 httpcore-benchmark/pom.xml | 2 +-
 httpcore-contrib/pom.xml   | 2 +-
 httpcore-nio/pom.xml       | 2 +-
 httpcore-osgi/pom.xml      | 2 +-
 httpcore/pom.xml           | 2 +-
 pom.xml                    | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f4a290e4/httpcore-ab/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-ab/pom.xml b/httpcore-ab/pom.xml
index 912b860..ee00597 100644
--- a/httpcore-ab/pom.xml
+++ b/httpcore-ab/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.3-SNAPSHOT</version>
+    <version>4.1.4-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-ab</artifactId>
   <name>HttpCore AB clone</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f4a290e4/httpcore-benchmark/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-benchmark/pom.xml b/httpcore-benchmark/pom.xml
index 9768f0f..0aed422 100644
--- a/httpcore-benchmark/pom.xml
+++ b/httpcore-benchmark/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.3-SNAPSHOT</version>
+    <version>4.1.4-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-benchmark</artifactId>
   <name>HttpCore Benchmarks</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f4a290e4/httpcore-contrib/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-contrib/pom.xml b/httpcore-contrib/pom.xml
index 084b71b..032e583 100644
--- a/httpcore-contrib/pom.xml
+++ b/httpcore-contrib/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.3-SNAPSHOT</version>
+    <version>4.1.4-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-contrib</artifactId>
   <name>HttpCore Contrib</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f4a290e4/httpcore-nio/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-nio/pom.xml b/httpcore-nio/pom.xml
index 43d6885..331d3d2 100644
--- a/httpcore-nio/pom.xml
+++ b/httpcore-nio/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.3-SNAPSHOT</version>
+    <version>4.1.4-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-nio</artifactId>
   <name>HttpCore NIO</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f4a290e4/httpcore-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-osgi/pom.xml b/httpcore-osgi/pom.xml
index 4d5c435..541c254 100644
--- a/httpcore-osgi/pom.xml
+++ b/httpcore-osgi/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.3-SNAPSHOT</version>
+    <version>4.1.4-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-osgi</artifactId>
   <name>HttpCore OSGi bundle</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f4a290e4/httpcore/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore/pom.xml b/httpcore/pom.xml
index c0e33c5..50ed6cb 100644
--- a/httpcore/pom.xml
+++ b/httpcore/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.3-SNAPSHOT</version>
+    <version>4.1.4-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore</artifactId>
   <name>HttpCore</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f4a290e4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c218ad9..15a2254 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,7 @@
   <groupId>org.apache.httpcomponents</groupId>
   <artifactId>httpcomponents-core</artifactId>
   <name>HttpComponents Core</name>
-  <version>4.1.3-SNAPSHOT</version>
+  <version>4.1.4-SNAPSHOT</version>
   <description>Core components to build HTTP enabled services</description>
   <url>http://hc.apache.org/httpcomponents-core</url>
   <inceptionYear>2005</inceptionYear>


[21/35] httpcomponents-core git commit: I/O event dispatchers to shut down the I/O session in case of a runtime exception (merged from trunk)

Posted by ol...@apache.org.
I/O event dispatchers to shut down the I/O session in case of a runtime exception (merged from trunk)

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1157057 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: cc013c33718bc443393b78d9b642a46f57f80cdb
Parents: f4a290e
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri Aug 12 11:30:47 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri Aug 12 11:30:47 2011 +0000

----------------------------------------------------------------------
 .../impl/nio/DefaultClientIOEventDispatch.java  |  71 +++++++---
 .../impl/nio/DefaultServerIOEventDispatch.java  |  54 ++++---
 .../impl/nio/ssl/SSLClientIOEventDispatch.java  | 139 +++++++++++--------
 .../impl/nio/ssl/SSLServerIOEventDispatch.java  | 136 ++++++++++--------
 4 files changed, 241 insertions(+), 159 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/cc013c33/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java
index bf2a61d..2215cc7 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java
@@ -120,23 +120,33 @@ public class DefaultClientIOEventDispatch implements IOEventDispatch {
      * @return newly created HTTP connection.
      */
     protected NHttpClientIOTarget createConnection(final IOSession session) {
-        return new DefaultNHttpClientConnection(
-                session,
-                createHttpResponseFactory(),
-                this.allocator,
-                this.params);
+    	try {
+            return new DefaultNHttpClientConnection(
+                    session,
+                    createHttpResponseFactory(),
+                    this.allocator,
+                    this.params);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void connected(final IOSession session) {
-        NHttpClientIOTarget conn = createConnection(session);
-        Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
-        session.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        this.handler.connected(conn, attachment);
+    	try {
+            NHttpClientIOTarget conn = createConnection(session);
+            Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
+            session.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+            this.handler.connected(conn, attachment);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void disconnected(final IOSession session) {
-        NHttpClientIOTarget conn =
-            (NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+        NHttpClientIOTarget conn = (NHttpClientIOTarget) session.getAttribute(
+        		ExecutionContext.HTTP_CONNECTION);
         if (conn != null) {
             this.handler.closed(conn);
         }
@@ -149,24 +159,39 @@ public class DefaultClientIOEventDispatch implements IOEventDispatch {
     }
 
     public void inputReady(final IOSession session) {
-        NHttpClientIOTarget conn =
-            (NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        conn.consumeInput(this.handler);
+    	try {
+            NHttpClientIOTarget conn = (NHttpClientIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            conn.consumeInput(this.handler);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void outputReady(final IOSession session) {
-        NHttpClientIOTarget conn =
-            (NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        conn.produceOutput(this.handler);
+    	try {
+            NHttpClientIOTarget conn = (NHttpClientIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            conn.produceOutput(this.handler);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void timeout(final IOSession session) {
-        NHttpClientIOTarget conn =
-            (NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        this.handler.timeout(conn);
+    	try {
+            NHttpClientIOTarget conn = (NHttpClientIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            this.handler.timeout(conn);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/cc013c33/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java
index ed573ce..1dfe6f9 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java
@@ -128,14 +128,19 @@ public class DefaultServerIOEventDispatch implements IOEventDispatch {
     }
 
     public void connected(final IOSession session) {
-        NHttpServerIOTarget conn = createConnection(session);
-        session.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        this.handler.connected(conn);
+    	try {
+            NHttpServerIOTarget conn = createConnection(session);
+            session.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+            this.handler.connected(conn);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void disconnected(final IOSession session) {
-        NHttpServerIOTarget conn =
-            (NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+        NHttpServerIOTarget conn = (NHttpServerIOTarget) session.getAttribute(
+        		ExecutionContext.HTTP_CONNECTION);
         if (conn != null) {
             this.handler.closed(conn);
         }
@@ -148,24 +153,39 @@ public class DefaultServerIOEventDispatch implements IOEventDispatch {
     }
 
     public void inputReady(final IOSession session) {
-        NHttpServerIOTarget conn =
-            (NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        conn.consumeInput(this.handler);
+    	try {
+            NHttpServerIOTarget conn = (NHttpServerIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            conn.consumeInput(this.handler);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void outputReady(final IOSession session) {
-        NHttpServerIOTarget conn =
-            (NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        conn.produceOutput(this.handler);
+    	try {
+            NHttpServerIOTarget conn = (NHttpServerIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            conn.produceOutput(this.handler);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void timeout(final IOSession session) {
-        NHttpServerIOTarget conn =
-            (NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        this.handler.timeout(conn);
+    	try {
+            NHttpServerIOTarget conn = (NHttpServerIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            this.handler.timeout(conn);
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/cc013c33/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
index 1fbf622..03471fc 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
@@ -186,32 +186,36 @@ public class SSLClientIOEventDispatch implements IOEventDispatch {
     }
 
     public void connected(final IOSession session) {
+    	try {
+            SSLIOSession sslSession = createSSLIOSession(
+                    session,
+                    this.sslcontext,
+                    this.sslHandler);
 
-        SSLIOSession sslSession = createSSLIOSession(
-                session,
-                this.sslcontext,
-                this.sslHandler);
-
-        NHttpClientIOTarget conn = createConnection(
-                sslSession);
+            NHttpClientIOTarget conn = createConnection(
+                    sslSession);
 
-        session.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        session.setAttribute(SSL_SESSION, sslSession);
+            session.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+            session.setAttribute(SSL_SESSION, sslSession);
 
-        Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
-        this.handler.connected(conn, attachment);
+            Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
+            this.handler.connected(conn, attachment);
 
-        try {
-            sslSession.bind(SSLMode.CLIENT, this.params);
-        } catch (SSLException ex) {
-            this.handler.exception(conn, ex);
-            sslSession.shutdown();
-        }
+            try {
+                sslSession.bind(SSLMode.CLIENT, this.params);
+            } catch (SSLException ex) {
+                this.handler.exception(conn, ex);
+                sslSession.shutdown();
+            }
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void disconnected(final IOSession session) {
-        NHttpClientIOTarget conn =
-            (NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
+        NHttpClientIOTarget conn = (NHttpClientIOTarget) session.getAttribute(
+        		ExecutionContext.HTTP_CONNECTION);
         if (conn != null) {
             this.handler.closed(conn);
         }
@@ -230,58 +234,73 @@ public class SSLClientIOEventDispatch implements IOEventDispatch {
     }
 
     public void inputReady(final IOSession session) {
-        NHttpClientIOTarget conn =
-            (NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        SSLIOSession sslSession =
-            (SSLIOSession) session.getAttribute(SSL_SESSION);
-        ensureNotNull(sslSession);
+    	try {
+	        NHttpClientIOTarget conn = (NHttpClientIOTarget) session.getAttribute(
+	        		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            SSLIOSession sslSession =
+                (SSLIOSession) session.getAttribute(SSL_SESSION);
+            ensureNotNull(sslSession);
 
-        try {
-            if (sslSession.isAppInputReady()) {
-                conn.consumeInput(this.handler);
+            try {
+                if (sslSession.isAppInputReady()) {
+                    conn.consumeInput(this.handler);
+                }
+                sslSession.inboundTransport();
+            } catch (IOException ex) {
+                this.handler.exception(conn, ex);
+                sslSession.shutdown();
             }
-            sslSession.inboundTransport();
-        } catch (IOException ex) {
-            this.handler.exception(conn, ex);
-            sslSession.shutdown();
-        }
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void outputReady(final IOSession session) {
-        NHttpClientIOTarget conn =
-            (NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        SSLIOSession sslSession =
-            (SSLIOSession) session.getAttribute(SSL_SESSION);
-        ensureNotNull(sslSession);
+    	try {
+	        NHttpClientIOTarget conn = (NHttpClientIOTarget) session.getAttribute(
+	        		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            SSLIOSession sslSession =
+                (SSLIOSession) session.getAttribute(SSL_SESSION);
+            ensureNotNull(sslSession);
 
-        try {
-            if (sslSession.isAppOutputReady()) {
-                conn.produceOutput(this.handler);
+            try {
+                if (sslSession.isAppOutputReady()) {
+                    conn.produceOutput(this.handler);
+                }
+                sslSession.outboundTransport();
+            } catch (IOException ex) {
+                this.handler.exception(conn, ex);
+                sslSession.shutdown();
             }
-            sslSession.outboundTransport();
-        } catch (IOException ex) {
-            this.handler.exception(conn, ex);
-            sslSession.shutdown();
-        }
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void timeout(final IOSession session) {
-        NHttpClientIOTarget conn =
-            (NHttpClientIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        SSLIOSession sslSession =
-            (SSLIOSession) session.getAttribute(SSL_SESSION);
-        ensureNotNull(sslSession);
+    	try {
+	        NHttpClientIOTarget conn = (NHttpClientIOTarget) session.getAttribute(
+	        		ExecutionContext.HTTP_CONNECTION);
+	        ensureNotNull(conn);
+	        SSLIOSession sslSession =
+	            (SSLIOSession) session.getAttribute(SSL_SESSION);
+	        ensureNotNull(sslSession);
 
-        this.handler.timeout(conn);
-        synchronized (sslSession) {
-            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
-                // The session failed to terminate cleanly
-                sslSession.shutdown();
-            }
-        }
+	        this.handler.timeout(conn);
+	        synchronized (sslSession) {
+	            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
+	                // The session failed to terminate cleanly
+	                sslSession.shutdown();
+	            }
+	        }
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/cc013c33/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
index d43c1fe..d4839a5 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
@@ -186,32 +186,35 @@ public class SSLServerIOEventDispatch implements IOEventDispatch {
     }
 
     public void connected(final IOSession session) {
+    	try {
+            SSLIOSession sslSession = createSSLIOSession(
+                    session,
+                    this.sslcontext,
+                    this.sslHandler);
 
-        SSLIOSession sslSession = createSSLIOSession(
-                session,
-                this.sslcontext,
-                this.sslHandler);
-
-        NHttpServerIOTarget conn = createConnection(
-                sslSession);
+            NHttpServerIOTarget conn = createConnection(
+                    sslSession);
 
-        session.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        session.setAttribute(SSL_SESSION, sslSession);
+            session.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+            session.setAttribute(SSL_SESSION, sslSession);
 
-        this.handler.connected(conn);
+            this.handler.connected(conn);
 
-        try {
-            sslSession.bind(SSLMode.SERVER, this.params);
-        } catch (SSLException ex) {
-            this.handler.exception(conn, ex);
-            sslSession.shutdown();
-        }
+            try {
+                sslSession.bind(SSLMode.SERVER, this.params);
+            } catch (SSLException ex) {
+                this.handler.exception(conn, ex);
+                sslSession.shutdown();
+            }
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void disconnected(final IOSession session) {
-        NHttpServerIOTarget conn =
-            (NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-
+    	NHttpServerIOTarget conn = (NHttpServerIOTarget) session.getAttribute(
+        		ExecutionContext.HTTP_CONNECTION);
         if (conn != null) {
             this.handler.closed(conn);
         }
@@ -230,58 +233,73 @@ public class SSLServerIOEventDispatch implements IOEventDispatch {
     }
 
     public void inputReady(final IOSession session) {
-        NHttpServerIOTarget conn =
-            (NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        SSLIOSession sslSession =
-            (SSLIOSession) session.getAttribute(SSL_SESSION);
-        ensureNotNull(sslSession);
+    	try {
+        	NHttpServerIOTarget conn = (NHttpServerIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            SSLIOSession sslSession =
+                (SSLIOSession) session.getAttribute(SSL_SESSION);
+            ensureNotNull(sslSession);
 
-        try {
-            if (sslSession.isAppInputReady()) {
-                conn.consumeInput(this.handler);
+            try {
+                if (sslSession.isAppInputReady()) {
+                    conn.consumeInput(this.handler);
+                }
+                sslSession.inboundTransport();
+            } catch (IOException ex) {
+                this.handler.exception(conn, ex);
+                sslSession.shutdown();
             }
-            sslSession.inboundTransport();
-        } catch (IOException ex) {
-            this.handler.exception(conn, ex);
-            sslSession.shutdown();
-        }
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void outputReady(final IOSession session) {
-        NHttpServerIOTarget conn =
-            (NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        SSLIOSession sslSession =
-            (SSLIOSession) session.getAttribute(SSL_SESSION);
-        ensureNotNull(sslSession);
+    	try {
+        	NHttpServerIOTarget conn = (NHttpServerIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            SSLIOSession sslSession =
+                (SSLIOSession) session.getAttribute(SSL_SESSION);
+            ensureNotNull(sslSession);
 
-        try {
-            if (sslSession.isAppOutputReady()) {
-                conn.produceOutput(this.handler);
+            try {
+                if (sslSession.isAppOutputReady()) {
+                    conn.produceOutput(this.handler);
+                }
+                sslSession.outboundTransport();
+            } catch (IOException ex) {
+                this.handler.exception(conn, ex);
+                sslSession.shutdown();
             }
-            sslSession.outboundTransport();
-        } catch (IOException ex) {
-            this.handler.exception(conn, ex);
-            sslSession.shutdown();
-        }
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
     public void timeout(final IOSession session) {
-        NHttpServerIOTarget conn =
-            (NHttpServerIOTarget) session.getAttribute(ExecutionContext.HTTP_CONNECTION);
-        ensureNotNull(conn);
-        SSLIOSession sslSession =
-            (SSLIOSession) session.getAttribute(SSL_SESSION);
-        ensureNotNull(sslSession);
+    	try {
+        	NHttpServerIOTarget conn = (NHttpServerIOTarget) session.getAttribute(
+            		ExecutionContext.HTTP_CONNECTION);
+            ensureNotNull(conn);
+            SSLIOSession sslSession =
+                (SSLIOSession) session.getAttribute(SSL_SESSION);
+            ensureNotNull(sslSession);
 
-        this.handler.timeout(conn);
-        synchronized (sslSession) {
-            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
-                // The session failed to cleanly terminate
-                sslSession.shutdown();
+            this.handler.timeout(conn);
+            synchronized (sslSession) {
+                if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
+                    // The session failed to cleanly terminate
+                    sslSession.shutdown();
+                }
             }
-        }
+    	} catch (RuntimeException ex) {
+    		session.shutdown();
+    		throw ex;
+    	}
     }
 
 }


[19/35] httpcomponents-core git commit: Updated HttpCore web site for 4.1.3 release

Posted by ol...@apache.org.
Updated HttpCore web site for 4.1.3 release

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1151572 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: ff5986bdf91d854216c5f2af4472e99db3de8978
Parents: e02ce07
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Wed Jul 27 18:01:46 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Wed Jul 27 18:01:46 2011 +0000

----------------------------------------------------------------------
 src/site/apt/download.apt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ff5986bd/src/site/apt/download.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/download.apt b/src/site/apt/download.apt
index 9c597b4..c4c6f72 100644
--- a/src/site/apt/download.apt
+++ b/src/site/apt/download.apt
@@ -42,24 +42,24 @@ HttpCore Downloads
     in your {{{http://maven.apache.org/guides/introduction/introduction-to-the-pom.html}pom.xml}} 
     by adding the following block to the dependency descriptor:
 
-* {HttpComponents Core 4.1.2}
+* {HttpComponents Core 4.1.3}
 
 -------------------------
   <dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcore</artifactId>
-    <version>4.1.2</version>
+    <version>4.1.3</version>
     <scope>compile</scope>
   </dependency>
 -------------------------
 
-* {HttpComponents Core NIO 4.1.2}
+* {HttpComponents Core NIO 4.1.3}
 
 -------------------------
   <dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcore-nio</artifactId>
-    <version>4.1.2</version>
+    <version>4.1.3</version>
     <scope>compile</scope>
   </dependency>
 -------------------------


[23/35] httpcomponents-core git commit: HTTPCORE-282: Newly created non-blocking I/O sessions to have READ interest op bit cleared per default due to a regression introduced by r1053669 (merged from trunk) Contributed by Sadeep Jayasumana Posted by ol...@apache.org.
HTTPCORE-282: Newly created non-blocking I/O sessions to have READ interest op bit cleared per default due to a regression introduced by r1053669 (merged from trunk)
Contributed by Sadeep Jayasumana <sadeep at wso2.com>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1204889 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 85263c20b75d5e984a2aba5b6cf574a4967d3b62
Parents: 76ed6f5
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Tue Nov 22 09:59:08 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Nov 22 09:59:08 2011 +0000

----------------------------------------------------------------------
 .gitignore                                                     | 6 ++++++
 RELEASE_NOTES.txt                                              | 5 +++++
 .../java/org/apache/http/impl/nio/NHttpConnectionBase.java     | 1 +
 3 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/85263c20/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..535b4cc
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.classpath
+.project
+.settings
+.clover
+.externalToolBuilders
+target

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/85263c20/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index f59bd02..e7d7526 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,11 @@
 Changes since 4.1.3
 -------------------
 
+* [HTTPCORE-282] Newly created non-blocking I/O sessions to have READ interest op bit cleared 
+  per default due to a regression introduced in release 4.1.1. This has a side effect on client
+  side non-blocking connections when running in the interest op queuing mode.
+  Contributed by Sadeep Jayasumana <sadeep at wso2.com> 
+
 * [HTTPCORE-268] Handle runtime exceptions thrown by SSLEngine.
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/85263c20/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index 4e2b192..980b883 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -156,6 +156,7 @@ public class NHttpConnectionBase
         this.session = session;
         this.context = new SessionHttpContext(this.session);
         this.session.setBufferStatus(this);
+        this.session.setEvent(EventMask.READ);
         this.remote = this.session.getRemoteAddress();
     }
 


[26/35] httpcomponents-core git commit: HTTPCORE-283: Workaround for a bug causing termination of the I/O reactor in case of exception thrown by NHttpServiceHandler#requestReceived or NHttpClientHandler#responseReceived methods. A more comprehensive fix

Posted by ol...@apache.org.
HTTPCORE-283: Workaround for a bug causing termination of the I/O reactor in case of exception thrown by NHttpServiceHandler#requestReceived or NHttpClientHandler#responseReceived methods. A more comprehensive fix for the bug applied to the (4.2 branch)

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1209164 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: d53511fdd67708a824b5956b8c538081fe7fd943
Parents: 2480204
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Thu Dec 1 17:31:09 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Thu Dec 1 17:31:09 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                                              | 5 +++++
 .../org/apache/http/impl/nio/DefaultNHttpClientConnection.java | 6 ++++++
 .../org/apache/http/impl/nio/DefaultNHttpServerConnection.java | 6 ++++++
 3 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d53511fd/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index a5148fb..cf2dadf 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,11 @@
 Changes since 4.1.3
 -------------------
 
+* [HTTPCORE-283] Workaround for a bug causing termination of the I/O reactor in case of exception 
+  thrown by NHttpServiceHandler#requestReceived or NHttpClientHandler#responseReceived
+  methods. A more comprehensive fix for the bug applied to the (4.2 branch).
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-281] ResponseConnControl protocol interceptor does not correctly populate connection
   persistence control headers when sending a HTTP/1.1 response message in response to a HTTP/1.0 
   request message.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d53511fd/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
index 78bd87f..d1036da 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
@@ -162,6 +162,9 @@ public class DefaultNHttpClientConnection
                         this.connMetrics.incrementResponseCount();
                     }
                     handler.responseReceived(this);
+                    if (this.session.isClosed()) {
+                        return;
+                    }
                     if (this.contentDecoder == null) {
                         resetInput();
                     }
@@ -172,6 +175,9 @@ public class DefaultNHttpClientConnection
             }
             if (this.contentDecoder != null) {
                 handler.inputReady(this, this.contentDecoder);
+                if (this.session.isClosed()) {
+                    return;
+                }
                 if (this.contentDecoder.isCompleted()) {
                     // Response entity received
                     // Ready to receive a new response

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d53511fd/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index 7064b62..2c0fe25 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -161,6 +161,9 @@ public class DefaultNHttpServerConnection
                     }
                     this.connMetrics.incrementRequestCount();
                     handler.requestReceived(this);
+                    if (this.session.isClosed()) {
+                        return;
+                    }
                     if (this.contentDecoder == null) {
                         // No request entity is expected
                         // Ready to receive a new request
@@ -173,6 +176,9 @@ public class DefaultNHttpServerConnection
             }
             if (this.contentDecoder != null) {
                 handler.inputReady(this, this.contentDecoder);
+                if (this.session.isClosed()) {
+                    return;
+                }
                 if (this.contentDecoder.isCompleted()) {
                     // Request entity received
                     // Ready to receive a new request


[18/35] httpcomponents-core git commit: HTTPCORE-266: SSLIOSession does not correctly terminate if the opposite end shuts down connection without sending 'close notify' message causing an infinite loop in the I/O dispatch thread

Posted by ol...@apache.org.
HTTPCORE-266: SSLIOSession does not correctly terminate if the opposite end shuts down connection without sending 'close notify' message causing an infinite loop in the I/O dispatch thread

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1150208 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: e02ce07793c0e9a91c924fcad8d641c93d5c1c47
Parents: 82b7e3d
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat Jul 23 19:52:24 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Jul 23 19:52:24 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                                         | 10 ++++++++++
 .../org/apache/http/impl/nio/reactor/SSLIOSession.java    |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e02ce077/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 1f47c4b..fe0f1f9 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,3 +1,13 @@
+Release 4.1.3
+-------------------
+
+This is an emergency release that fixes a severe regression in the non-blocking SSL I/O code 
+introduced in release 4.1.2.
+
+* [HTTPCORE-266] SSLIOSession does not correctly terminate if the opposite end shuts down connection 
+  without sending a 'close notify' message causing an infinite loop in the I/O dispatch thread.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 Release 4.1.2
 -------------------
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e02ce077/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
index 8c0a488..4cff03c 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
@@ -189,8 +189,8 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
     }
 
     private void updateEventMask() {
-        if (this.status == CLOSING &&
-                this.sslEngine.isInboundDone() && this.sslEngine.isOutboundDone()) {
+        if (this.status == CLOSING && this.sslEngine.isOutboundDone()
+                && (this.endOfStream || this.sslEngine.isInboundDone())) {
             this.status = CLOSED;
         }
         if (this.status == CLOSED) {


[16/35] httpcomponents-core git commit: Updated web site for HttpCore 4.1.2 release

Posted by ol...@apache.org.
Updated web site for HttpCore 4.1.2 release

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1144814 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 8a033e758e5f020ee779210b148e92cb3345b4be
Parents: 31b7131
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Jul 10 10:47:57 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Jul 10 10:47:57 2011 +0000

----------------------------------------------------------------------
 src/site/apt/download.apt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8a033e75/src/site/apt/download.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/download.apt b/src/site/apt/download.apt
index 9386dc7..9c597b4 100644
--- a/src/site/apt/download.apt
+++ b/src/site/apt/download.apt
@@ -42,24 +42,24 @@ HttpCore Downloads
     in your {{{http://maven.apache.org/guides/introduction/introduction-to-the-pom.html}pom.xml}} 
     by adding the following block to the dependency descriptor:
 
-* {HttpComponents Core 4.1.1}
+* {HttpComponents Core 4.1.2}
 
 -------------------------
   <dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcore</artifactId>
-    <version>4.1.1</version>
+    <version>4.1.2</version>
     <scope>compile</scope>
   </dependency>
 -------------------------
 
-* {HttpComponents Core NIO 4.1.1}
+* {HttpComponents Core NIO 4.1.2}
 
 -------------------------
   <dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcore-nio</artifactId>
-    <version>4.1.1</version>
+    <version>4.1.2</version>
     <scope>compile</scope>
   </dependency>
 -------------------------


[03/35] httpcomponents-core git commit: Restored original method visibility

Posted by ol...@apache.org.
Restored original method visibility

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1101174 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 49edde1868f38fa90c3ce36e6cc56c01e941aea6
Parents: 77e0583
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Mon May 9 19:53:26 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Mon May 9 19:53:26 2011 +0000

----------------------------------------------------------------------
 httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49edde18/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java b/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
index c85c831..b4bba9b 100644
--- a/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
+++ b/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
@@ -148,7 +148,7 @@ public class BasicHttpParams extends AbstractHttpParams implements Serializable,
         return clone;
     }
 
-    private void copyParams(HttpParams target) {
+    protected void copyParams(HttpParams target) {
         Iterator iter = parameters.entrySet().iterator();
         while (iter.hasNext()) {
             Map.Entry me = (Map.Entry) iter.next();


[14/35] httpcomponents-core git commit: fix possible NPE if the connection is closed - and the address is null

Posted by ol...@apache.org.
fix possible NPE if the connection is closed - and the address is null


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1144469 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 34efab70d8b33e2ea81d08785de01b08a1186db3
Parents: 1caa7be
Author: Asankha Chamath Perera <as...@apache.org>
Authored: Fri Jul 8 20:00:42 2011 +0000
Committer: Asankha Chamath Perera <as...@apache.org>
Committed: Fri Jul 8 20:00:42 2011 +0000

----------------------------------------------------------------------
 .../impl/nio/DefaultNHttpClientConnection.java  | 20 +++++++---
 .../impl/nio/DefaultNHttpServerConnection.java  | 20 +++++++---
 .../http/impl/nio/reactor/IOSessionImpl.java    | 41 +++++++++++---------
 3 files changed, 51 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/34efab70/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
index bcca530..78bd87f 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
@@ -29,6 +29,7 @@ package org.apache.http.impl.nio;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.net.SocketAddress;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
@@ -258,11 +259,18 @@ public class DefaultNHttpClientConnection
     public String toString() {
         StringBuilder buf = new StringBuilder();
 
-        if (this.session.getRemoteAddress() instanceof InetSocketAddress &&
-            this.session.getLocalAddress()  instanceof InetSocketAddress) {
+        final SocketAddress remoteAddress = this.session.getRemoteAddress();
+        final SocketAddress localAddress = this.session.getLocalAddress();
 
-            final InetSocketAddress remote = ((InetSocketAddress) this.session.getRemoteAddress());
-            final InetSocketAddress local  = ((InetSocketAddress) this.session.getLocalAddress());
+        if (remoteAddress == null || localAddress == null) {
+            return "[CLOSED]";
+        }
+
+        if (remoteAddress instanceof InetSocketAddress &&
+            localAddress instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) remoteAddress);
+            final InetSocketAddress local  = ((InetSocketAddress) localAddress);
 
             buf.append(local.getAddress() != null ? local.getAddress().getHostAddress() : local.getAddress())
             .append(':')
@@ -273,9 +281,9 @@ public class DefaultNHttpClientConnection
             .append(remote.getPort());
 
         } else {
-            buf.append(this.session.getLocalAddress())
+            buf.append(localAddress)
             .append("->")
-            .append(this.session.getRemoteAddress());
+            .append(remoteAddress);
         }
 
         return buf.toString();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/34efab70/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index c78ae24..7064b62 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -29,6 +29,7 @@ package org.apache.http.impl.nio;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.net.SocketAddress;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
@@ -260,11 +261,18 @@ public class DefaultNHttpServerConnection
     public String toString() {
         StringBuilder buf = new StringBuilder();
 
-        if (this.session.getRemoteAddress() instanceof InetSocketAddress &&
-            this.session.getLocalAddress()  instanceof InetSocketAddress) {
+        final SocketAddress remoteAddress = this.session.getRemoteAddress();
+        final SocketAddress localAddress  = this.session.getLocalAddress();
 
-            final InetSocketAddress remote = ((InetSocketAddress) this.session.getRemoteAddress());
-            final InetSocketAddress local  = ((InetSocketAddress) this.session.getLocalAddress());
+        if (remoteAddress == null || localAddress == null) {
+            return "[CLOSED]";
+        }
+
+        if (remoteAddress instanceof InetSocketAddress &&
+            localAddress instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) remoteAddress);
+            final InetSocketAddress local  = ((InetSocketAddress) localAddress);
 
             buf.append(remote.getAddress() != null ? remote.getAddress().getHostAddress() : remote.getAddress())
             .append(':')
@@ -275,9 +283,9 @@ public class DefaultNHttpServerConnection
             .append(local.getPort());
 
         } else {
-            buf.append(this.session.getRemoteAddress())
+            buf.append(remoteAddress)
             .append("->")
-            .append(this.session.getLocalAddress());
+            .append(localAddress);
         }
 
         return buf.toString();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/34efab70/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index 7e63cde..2c3f802 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -310,24 +310,29 @@ public class IOSessionImpl implements IOSession {
     public synchronized String toString() {
         StringBuilder buffer = new StringBuilder();
 
-        if (getRemoteAddress() instanceof InetSocketAddress &&
-            getLocalAddress()  instanceof InetSocketAddress) {
-
-            final InetSocketAddress remote = ((InetSocketAddress) getRemoteAddress());
-            final InetSocketAddress local  = ((InetSocketAddress) getLocalAddress());
-
-            buffer.append(local.getAddress() != null ? local.getAddress().getHostAddress() : local.getAddress())
-            .append(':')
-            .append(local.getPort())
-            .append("<->")
-            .append(remote.getAddress() != null ? remote.getAddress().getHostAddress() : remote.getAddress())
-            .append(':')
-            .append(remote.getPort());
-
-        } else {
-            buffer.append(getLocalAddress())
-            .append("<->")
-            .append(getRemoteAddress());
+        final SocketAddress remoteAddress = getRemoteAddress();
+        final SocketAddress localAddress = getLocalAddress();
+
+        if (remoteAddress != null && localAddress != null) {
+            if (remoteAddress instanceof InetSocketAddress &&
+                localAddress instanceof InetSocketAddress) {
+
+                final InetSocketAddress remote = ((InetSocketAddress) remoteAddress);
+                final InetSocketAddress local  = ((InetSocketAddress) localAddress);
+
+                buffer.append(local.getAddress() != null ? local.getAddress().getHostAddress() : local.getAddress())
+                .append(':')
+                .append(local.getPort())
+                .append("<->")
+                .append(remote.getAddress() != null ? remote.getAddress().getHostAddress() : remote.getAddress())
+                .append(':')
+                .append(remote.getPort());
+
+            } else {
+                buffer.append(localAddress)
+                .append("<->")
+                .append(remoteAddress);
+            }
         }
 
         buffer.append("[");


[04/35] httpcomponents-core git commit: Updated download page for release 4.1.1

Posted by ol...@apache.org.
Updated download page for release 4.1.1

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1101187 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 26632eeffb3dd29b10266c8cce3978a13091d420
Parents: 49edde1
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Mon May 9 19:57:23 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Mon May 9 19:57:23 2011 +0000

----------------------------------------------------------------------
 src/site/apt/download.apt | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/26632eef/src/site/apt/download.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/download.apt b/src/site/apt/download.apt
index 47114fe..9386dc7 100644
--- a/src/site/apt/download.apt
+++ b/src/site/apt/download.apt
@@ -33,7 +33,7 @@ HttpCore Downloads
     The latest release available for download:
 
     {{{http://hc.apache.org/downloads.cgi}Release packages}} - 
-    {{{http://www.apache.org/dist/httpcomponents/httpcore/RELEASE_NOTES.txt}Release Notes}} -
+    {{{http://www.apache.org/dist/httpcomponents/httpcore/RELEASE_NOTES-4.1.x.txt}Release Notes}} -
     {{{http://www.apache.org/licenses/LICENSE-2.0.html}License}}
 
 {Dependency management with Maven}
@@ -42,24 +42,24 @@ HttpCore Downloads
     in your {{{http://maven.apache.org/guides/introduction/introduction-to-the-pom.html}pom.xml}} 
     by adding the following block to the dependency descriptor:
 
-* {HttpComponents Core 4.1}
+* {HttpComponents Core 4.1.1}
 
 -------------------------
   <dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcore</artifactId>
-    <version>4.1</version>
+    <version>4.1.1</version>
     <scope>compile</scope>
   </dependency>
 -------------------------
 
-* {HttpComponents Core NIO 4.1}
+* {HttpComponents Core NIO 4.1.1}
 
 -------------------------
   <dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcore-nio</artifactId>
-    <version>4.1</version>
+    <version>4.1.1</version>
     <scope>compile</scope>
   </dependency>
 -------------------------


[11/35] httpcomponents-core git commit: merged connection debugging for NIO from trunk

Posted by ol...@apache.org.
merged connection debugging for NIO from trunk


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1142757 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 8eef5fbd880c13b4da42e1768309b72032ed87b6
Parents: 886e6aa
Author: Asankha Chamath Perera <as...@apache.org>
Authored: Mon Jul 4 18:46:13 2011 +0000
Committer: Asankha Chamath Perera <as...@apache.org>
Committed: Mon Jul 4 18:46:13 2011 +0000

----------------------------------------------------------------------
 .../impl/nio/DefaultNHttpClientConnection.java  | 27 ++++++++++++++++++++
 .../impl/nio/DefaultNHttpServerConnection.java  | 27 ++++++++++++++++++++
 .../http/impl/nio/NHttpConnectionBase.java      | 13 ++++------
 .../http/impl/nio/reactor/IOSessionImpl.java    | 26 +++++++++++++++++--
 4 files changed, 83 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8eef5fbd/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
index e66fa29..c7abf7a 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
@@ -28,6 +28,7 @@
 package org.apache.http.impl.nio;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
@@ -254,4 +255,30 @@ public class DefaultNHttpClientConnection
         return this.request != null;
     }
 
+    public String toString() {
+        StringBuilder buf = new StringBuilder();
+
+        if (this.session.getRemoteAddress() instanceof InetSocketAddress &&
+            this.session.getLocalAddress()  instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) this.session.getRemoteAddress());
+            final InetSocketAddress local  = ((InetSocketAddress) this.session.getLocalAddress());
+
+            buf.append(local.getAddress().getHostAddress())
+            .append(':')
+            .append(local.getPort())
+            .append("->")
+            .append(remote.getAddress().getHostAddress())
+            .append(':')
+            .append(remote.getPort());
+
+        } else {
+            buf.append(this.session.getLocalAddress())
+            .append("->")
+            .append(this.session.getRemoteAddress());
+        }
+
+        return buf.toString();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8eef5fbd/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index a511c8d..59592de 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -28,6 +28,7 @@
 package org.apache.http.impl.nio;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
@@ -256,4 +257,30 @@ public class DefaultNHttpServerConnection
         return this.response != null;
     }
 
+    public String toString() {
+        StringBuilder buf = new StringBuilder();
+
+        if (this.session.getRemoteAddress() instanceof InetSocketAddress &&
+            this.session.getLocalAddress()  instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) this.session.getRemoteAddress());
+            final InetSocketAddress local  = ((InetSocketAddress) this.session.getLocalAddress());
+
+            buf.append(remote.getAddress().getHostAddress())
+            .append(':')
+            .append(remote.getPort())
+            .append("->")
+            .append(local.getAddress().getHostAddress())
+            .append(':')
+            .append(local.getPort());
+
+        } else {
+            buf.append(this.session.getRemoteAddress())
+            .append("->")
+            .append(this.session.getLocalAddress());
+        }
+
+        return buf.toString();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8eef5fbd/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index 1cfd500..4e2b192 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -412,14 +412,11 @@ public class NHttpConnectionBase
 
     @Override
     public String toString() {
-        StringBuffer buffer = new StringBuffer();
-        buffer.append("[");
-        buffer.append(this.remote);
-        if (this.status == CLOSED) {
-            buffer.append("(closed)");
-        }
-        buffer.append("]");
-        return buffer.toString();
+        StringBuilder buf = new StringBuilder();
+        buf.append(this.session.getLocalAddress())
+            .append("<->")
+            .append(this.session.getRemoteAddress());
+        return buf.toString();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8eef5fbd/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index 31e6682..dbc4d99 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -28,6 +28,7 @@
 package org.apache.http.impl.nio.reactor;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.nio.channels.ByteChannel;
 import java.nio.channels.Channel;
@@ -290,7 +291,7 @@ public class IOSessionImpl implements IOSession {
         this.lastAccessTime = now;
     }
 
-    private static void formatOps(final StringBuffer buffer, int ops) {
+    private static void formatOps(final StringBuilder buffer, int ops) {
         if ((ops & SelectionKey.OP_READ) > 0) {
             buffer.append('r');
         }
@@ -307,7 +308,28 @@ public class IOSessionImpl implements IOSession {
 
     @Override
     public synchronized String toString() {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
+
+        if (getRemoteAddress() instanceof InetSocketAddress &&
+            getLocalAddress()  instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) getRemoteAddress());
+            final InetSocketAddress local  = ((InetSocketAddress) getLocalAddress());
+
+            buffer.append(local.getAddress().getHostAddress())
+            .append(':')
+            .append(local.getPort())
+            .append("<->")
+            .append(remote.getAddress().getHostAddress())
+            .append(':')
+            .append(remote.getPort());
+
+        } else {
+            buffer.append(getLocalAddress())
+            .append("<->")
+            .append(getRemoteAddress());
+        }
+
         buffer.append("[");
         switch (this.status) {
         case ACTIVE:


[33/35] httpcomponents-core git commit: Simplified site content and assembly generation

Posted by ol...@apache.org.
Simplified site content and assembly generation

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1233986 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: c00ffe21fc548ca3aecf868f2efe25e1f1cde04f
Parents: c1a1688
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri Jan 20 16:22:46 2012 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri Jan 20 16:22:46 2012 +0000

----------------------------------------------------------------------
 pom.xml                        | 32 +++++++++++++++++++++++++++-----
 src/main/assembly/bin.xml      | 22 +++-------------------
 src/main/assembly/osgi-bin.xml | 22 +++-------------------
 3 files changed, 33 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c00ffe21/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1e9a98f..889c034 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,6 +135,15 @@
       </plugin>
       <plugin>
         <artifactId>maven-javadoc-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>javadoc-aggregate</id>
+            <goals>
+              <goal>aggregate</goal>
+            </goals>
+            <phase>pre-site</phase>
+          </execution>
+        </executions>
         <configuration>
           <!-- reduce console output. Can override with -Dquiet=false -->
           <quiet>true</quiet>
@@ -189,6 +198,16 @@
             <scope>runtime</scope>
           </dependency>
         </dependencies>
+        <executions>
+          <execution>
+            <id>tutorial-site</id>
+            <goals>
+              <goal>generate-html</goal>
+              <goal>generate-pdf</goal>
+            </goals>
+            <phase>pre-site</phase>
+          </execution>
+        </executions>        
         <configuration>
           <includes>index.xml</includes>
           <chunkedOutput>true</chunkedOutput>
@@ -203,13 +222,14 @@
             </entity>
           </entities>
           <postProcess>
-            <copy todir="target/site/tutorial">
-              <fileset dir="target/docbkx">
+            <copy todir="target/site/tutorial/html" 
+              failonerror="false">
+              <fileset dir="target/docbkx/html/index">
                 <include name="**/*.html" />
-                <include name="**/*.pdf" />
               </fileset>
             </copy>
-            <copy todir="target/site/tutorial/html">
+            <copy todir="target/site/tutorial/html" 
+              failonerror="false">
               <fileset dir="src/docbkx/resources">
                 <include name="**/*.css" />
                 <include name="**/*.png" />
@@ -217,7 +237,9 @@
                 <include name="**/*.jpg" />
               </fileset>
             </copy>
-            <move file="target/site/tutorial/pdf/index.pdf" tofile="target/site/tutorial/pdf/httpcore-tutorial.pdf" failonerror="false" />
+            <copy file="target/docbkx/pdf/index.pdf" 
+                  tofile="target/site/tutorial/pdf/httpcore-tutorial.pdf" 
+                  failonerror="false"/>
           </postProcess>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c00ffe21/src/main/assembly/bin.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/bin.xml b/src/main/assembly/bin.xml
index 018b857..5f97fb9 100644
--- a/src/main/assembly/bin.xml
+++ b/src/main/assembly/bin.xml
@@ -61,18 +61,10 @@
           <directory>target/site/apidocs</directory>
           <outputDirectory>javadoc</outputDirectory>
         </fileSet>
-        <!-- Tutorial (HTML) -->
+        <!-- Tutorial -->
         <fileSet>
-          <directory>target/docbkx/html</directory>
-          <outputDirectory>tutorial/html</outputDirectory>
-        </fileSet>
-        <fileSet>
-          <directory>src/docbkx/resources/css</directory>
-          <outputDirectory>tutorial/html/css</outputDirectory>
-        </fileSet>
-        <fileSet>
-          <directory>src/docbkx/resources/images</directory>
-          <outputDirectory>tutorial/html/images</outputDirectory>
+          <directory>target/site/tutorial</directory>
+          <outputDirectory>tutorial</outputDirectory>
         </fileSet>
         <!-- Examples: base module -->
         <fileSet>
@@ -91,12 +83,4 @@
           </includes>
         </fileSet>
     </fileSets>
-    <files>
-        <!-- Tutorial (PDF) -->
-        <file>
-          <source>target/docbkx/pdf/index.pdf</source>
-          <outputDirectory>tutorial/pdf</outputDirectory>
-          <destName>httpcore-tutorial.pdf</destName>
-        </file>
-    </files>
 </assembly>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c00ffe21/src/main/assembly/osgi-bin.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/osgi-bin.xml b/src/main/assembly/osgi-bin.xml
index 877cc43..755c267 100644
--- a/src/main/assembly/osgi-bin.xml
+++ b/src/main/assembly/osgi-bin.xml
@@ -55,18 +55,10 @@
           <directory>target/site/apidocs</directory>
           <outputDirectory>javadoc</outputDirectory>
         </fileSet>
-        <!-- Tutorial (HTML) -->
+        <!-- Tutorial -->
         <fileSet>
-          <directory>target/docbkx/html</directory>
-          <outputDirectory>tutorial/html</outputDirectory>
-        </fileSet>
-        <fileSet>
-          <directory>src/docbkx/resources/css</directory>
-          <outputDirectory>tutorial/html/css</outputDirectory>
-        </fileSet>
-        <fileSet>
-          <directory>src/docbkx/resources/images</directory>
-          <outputDirectory>tutorial/html/images</outputDirectory>
+          <directory>target/site/tutorial</directory>
+          <outputDirectory>tutorial</outputDirectory>
         </fileSet>
         <!-- Examples: base module -->
         <fileSet>
@@ -85,12 +77,4 @@
           </includes>
         </fileSet>
     </fileSets>
-    <files>
-        <!-- Tutorial (PDF) -->
-        <file>
-          <source>target/docbkx/pdf/index.pdf</source>
-          <outputDirectory>tutorial/pdf</outputDirectory>
-          <destName>httpcore-tutorial.pdf</destName>
-        </file>
-    </files>
 </assembly>


[06/35] httpcomponents-core git commit: Upgraded project version to 4.1.2-SNAPSHOT

Posted by ol...@apache.org.
Upgraded project version to 4.1.2-SNAPSHOT

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1104516 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 7b3c167a012000bde4e25023df5f8c9400154057
Parents: ef786ef
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Tue May 17 20:10:30 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue May 17 20:10:30 2011 +0000

----------------------------------------------------------------------
 httpcore-ab/pom.xml        | 2 +-
 httpcore-benchmark/pom.xml | 2 +-
 httpcore-contrib/pom.xml   | 2 +-
 httpcore-nio/pom.xml       | 2 +-
 httpcore-osgi/pom.xml      | 2 +-
 httpcore/pom.xml           | 2 +-
 pom.xml                    | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/7b3c167a/httpcore-ab/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-ab/pom.xml b/httpcore-ab/pom.xml
index baee767..75e059a 100644
--- a/httpcore-ab/pom.xml
+++ b/httpcore-ab/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.1-SNAPSHOT</version>
+    <version>4.1.2-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-ab</artifactId>
   <name>HttpCore AB clone</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/7b3c167a/httpcore-benchmark/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-benchmark/pom.xml b/httpcore-benchmark/pom.xml
index ee99d95..29abae7 100644
--- a/httpcore-benchmark/pom.xml
+++ b/httpcore-benchmark/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.1-SNAPSHOT</version>
+    <version>4.1.2-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-benchmark</artifactId>
   <name>HttpCore Benchmarks</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/7b3c167a/httpcore-contrib/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-contrib/pom.xml b/httpcore-contrib/pom.xml
index 71219f6..9c55258 100644
--- a/httpcore-contrib/pom.xml
+++ b/httpcore-contrib/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.1-SNAPSHOT</version>
+    <version>4.1.2-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-contrib</artifactId>
   <name>HttpCore Contrib</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/7b3c167a/httpcore-nio/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-nio/pom.xml b/httpcore-nio/pom.xml
index 0e38bc3..9208265 100644
--- a/httpcore-nio/pom.xml
+++ b/httpcore-nio/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.1-SNAPSHOT</version>
+    <version>4.1.2-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-nio</artifactId>
   <name>HttpCore NIO</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/7b3c167a/httpcore-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-osgi/pom.xml b/httpcore-osgi/pom.xml
index 0fb494c..644925a 100644
--- a/httpcore-osgi/pom.xml
+++ b/httpcore-osgi/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.1-SNAPSHOT</version>
+    <version>4.1.2-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-osgi</artifactId>
   <name>HttpCore OSGi bundle</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/7b3c167a/httpcore/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore/pom.xml b/httpcore/pom.xml
index 654631d..1b26447 100644
--- a/httpcore/pom.xml
+++ b/httpcore/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.1-SNAPSHOT</version>
+    <version>4.1.2-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore</artifactId>
   <name>HttpCore</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/7b3c167a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e0642f3..b0e0bb5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,7 @@
   <groupId>org.apache.httpcomponents</groupId>
   <artifactId>httpcomponents-core</artifactId>
   <name>HttpComponents Core</name>
-  <version>4.1.1-SNAPSHOT</version>
+  <version>4.1.2-SNAPSHOT</version>
   <description>Core components to build HTTP enabled services</description>
   <url>http://hc.apache.org/httpcomponents-core</url>
   <inceptionYear>2005</inceptionYear>


[35/35] httpcomponents-core git commit: Fully merged the fix for HTTPCORE-296

Posted by ol...@apache.org.
Fully merged the fix for HTTPCORE-296

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1302143 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 9d0d6115caf7ade10012df136d8f47bef0711288
Parents: e45e29f
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Mar 18 15:48:22 2012 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Mar 18 15:48:22 2012 +0000

----------------------------------------------------------------------
 .../impl/nio/DefaultNHttpServerConnection.java  |  2 +-
 .../http/impl/nio/NHttpConnectionBase.java      | 23 -----------------
 .../http/impl/AbstractHttpServerConnection.java |  2 +-
 .../DisallowIdentityContentLengthStrategy.java  |  2 --
 .../impl/entity/LaxContentLengthStrategy.java   | 27 ++++++++++++++++----
 .../entity/StrictContentLengthStrategy.java     | 27 ++++++++++++++++----
 .../protocol/TestHttpServiceAndExecutor.java    |  2 +-
 7 files changed, 47 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9d0d6115/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index f180954..43b3056 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -97,7 +97,7 @@ public class DefaultNHttpServerConnection
 
     @Override
     protected ContentLengthStrategy createIncomingContentStrategy() {
-        return new DisallowIdentityContentLengthStrategy(new LaxContentLengthStrategy());
+        return new DisallowIdentityContentLengthStrategy(new LaxContentLengthStrategy(0));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9d0d6115/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index a1f6b91..cbc8e83 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -159,38 +159,15 @@ public class NHttpConnectionBase
         this.remote = this.session.getRemoteAddress();
     }
 
-    /**
-<<<<<<< HEAD
-=======
-     * Binds the connection to a different {@link IOSession}. This may be necessary
-     * when the underlying I/O session gets upgraded with SSL/TLS encryption.
-     *
-     * @since 4.2
-     */
-    protected void bind(final IOSession session) {
-        if (session == null) {
-            throw new IllegalArgumentException("I/O session may not be null");
-        }
-        this.session.setBufferStatus(null);
-        setSession(session);
-    }
-
-    /**
-     * @since 4.2
-     */
     protected ContentLengthStrategy createIncomingContentStrategy() {
         return new LaxContentLengthStrategy();
     }
 
-    /**
-     * @since 4.2
-     */
     protected ContentLengthStrategy createOutgoingContentStrategy() {
         return new StrictContentLengthStrategy();
     }
 
     /**
->>>>>>> 74acee1... HTTPCORE-296: server side connections (both blocking and non-blocking) can now handle entity enclosing requests without Content-Length and Transfer-Encoding headers
      * @since 4.1
      */
     protected HttpTransportMetricsImpl createTransportMetrics() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9d0d6115/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java b/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
index 322c946..3485095 100644
--- a/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
@@ -116,7 +116,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
      */
     protected EntityDeserializer createEntityDeserializer() {
         return new EntityDeserializer(new DisallowIdentityContentLengthStrategy(
-                new LaxContentLengthStrategy()));
+                new LaxContentLengthStrategy(0)));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9d0d6115/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java b/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java
index 8a5ba49..17d0b0b 100644
--- a/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java
+++ b/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java
@@ -35,8 +35,6 @@ import org.apache.http.entity.ContentLengthStrategy;
 /**
  * Decorator for  {@link ContentLengthStrategy} implementations that disallows the use of 
  * identity transfer encoding. 
- *
- * @since 4.2
  */
 public class DisallowIdentityContentLengthStrategy implements ContentLengthStrategy {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9d0d6115/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java b/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
index 72b0425..45c0438 100644
--- a/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
+++ b/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
@@ -55,8 +55,25 @@ import org.apache.http.protocol.HTTP;
  */
 public class LaxContentLengthStrategy implements ContentLengthStrategy {
 
-    public LaxContentLengthStrategy() {
+    private final int implicitLen;
+    
+    /**
+     * Creates <tt>LaxContentLengthStrategy</tt> instance with the given length used per default
+     * when content length is not explicitly specified in the message.
+     * 
+     * @param implicit implicit content length.
+     */
+    public LaxContentLengthStrategy(int implicitLen) {
         super();
+        this.implicitLen = implicitLen;
+    }
+
+    /**
+     * Creates <tt>LaxContentLengthStrategy</tt> instance. {@link ContentLengthStrategy#IDENTITY} 
+     * is used per default when content length is not explicitly specified in the message.
+     */
+    public LaxContentLengthStrategy() {
+        this(IDENTITY);
     }
 
     public long determineLength(final HttpMessage message) throws HttpException {
@@ -68,7 +85,6 @@ public class LaxContentLengthStrategy implements ContentLengthStrategy {
         boolean strict = params.isParameterTrue(CoreProtocolPNames.STRICT_TRANSFER_ENCODING);
 
         Header transferEncodingHeader = message.getFirstHeader(HTTP.TRANSFER_ENCODING);
-        Header contentLengthHeader = message.getFirstHeader(HTTP.CONTENT_LEN);
         // We use Transfer-Encoding if present and ignore Content-Length.
         // RFC2616, 4.4 item number 3
         if (transferEncodingHeader != null) {
@@ -104,7 +120,9 @@ public class LaxContentLengthStrategy implements ContentLengthStrategy {
                 }
                 return IDENTITY;
             }
-        } else if (contentLengthHeader != null) {
+        }
+        Header contentLengthHeader = message.getFirstHeader(HTTP.CONTENT_LEN);
+        if (contentLengthHeader != null) {
             long contentlen = -1;
             Header[] headers = message.getHeaders(HTTP.CONTENT_LEN);
             if (strict && headers.length > 1) {
@@ -127,9 +145,8 @@ public class LaxContentLengthStrategy implements ContentLengthStrategy {
             } else {
                 return IDENTITY;
             }
-        } else {
-            return IDENTITY;
         }
+        return this.implicitLen;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9d0d6115/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java b/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
index 8575d3d..3054d85 100644
--- a/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
+++ b/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
@@ -47,8 +47,25 @@ import org.apache.http.protocol.HTTP;
  */
 public class StrictContentLengthStrategy implements ContentLengthStrategy {
 
-    public StrictContentLengthStrategy() {
+    private final int implicitLen;
+    
+    /**
+     * Creates <tt>StrictContentLengthStrategy</tt> instance with the given length used per default
+     * when content length is not explicitly specified in the message.
+     * 
+     * @param implicit implicit content length.
+     */
+    public StrictContentLengthStrategy(int implicitLen) {
         super();
+        this.implicitLen = implicitLen;
+    }
+
+    /**
+     * Creates <tt>StrictContentLengthStrategy</tt> instance. {@link ContentLengthStrategy#IDENTITY} 
+     * is used per default when content length is not explicitly specified in the message.
+     */
+    public StrictContentLengthStrategy() {
+        this(IDENTITY);
     }
 
     public long determineLength(final HttpMessage message) throws HttpException {
@@ -59,7 +76,6 @@ public class StrictContentLengthStrategy implements ContentLengthStrategy {
         // it is either missing or has the single value "chunked". So we
         // treat it as a single-valued header here.
         Header transferEncodingHeader = message.getFirstHeader(HTTP.TRANSFER_ENCODING);
-        Header contentLengthHeader = message.getFirstHeader(HTTP.CONTENT_LEN);
         if (transferEncodingHeader != null) {
             String s = transferEncodingHeader.getValue();
             if (HTTP.CHUNK_CODING.equalsIgnoreCase(s)) {
@@ -75,7 +91,9 @@ public class StrictContentLengthStrategy implements ContentLengthStrategy {
                 throw new ProtocolException(
                         "Unsupported transfer encoding: " + s);
             }
-        } else if (contentLengthHeader != null) {
+        }
+        Header contentLengthHeader = message.getFirstHeader(HTTP.CONTENT_LEN);
+        if (contentLengthHeader != null) {
             String s = contentLengthHeader.getValue();
             try {
                 long len = Long.parseLong(s);
@@ -86,9 +104,8 @@ public class StrictContentLengthStrategy implements ContentLengthStrategy {
             } catch (NumberFormatException e) {
                 throw new ProtocolException("Invalid content length: " + s);
             }
-        } else {
-            return IDENTITY;
         }
+        return this.implicitLen;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9d0d6115/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java b/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
index 660a10a..15f945d 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
@@ -851,7 +851,7 @@ public class TestHttpServiceAndExecutor extends TestCase {
                             new RequestExpectContinue() }));
             
             HttpResponse response = this.client.execute(post, host, conn);
-            assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
+            assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         } finally {
             conn.close();
             this.server.shutdown();


[31/35] httpcomponents-core git commit: Upgraded parent POM to version 5; fixed typo in the release notes

Posted by ol...@apache.org.
Upgraded parent POM to version 5; fixed typo in the release notes

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1220444 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 5d4113f214b3cfcccbe92f897138ac4ec12baac5
Parents: f2c14f9
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Dec 18 16:07:56 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Dec 18 16:07:56 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt | 2 +-
 pom.xml           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5d4113f2/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index b45a5bb..17ad9f0 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,7 +1,7 @@
 Release 4.1.4
 -------------------
 
-This is a maintenance release that fixes a number of bugs found since release 4.1.4. It is also 
+This is a maintenance release that fixes a number of bugs found since release 4.1.3. It is also 
 likely to be the last release in the 4.1.x branch.
 
 * [HTTPCORE-286] Canceled I/O session can cause an IllegalStateException in BaseIOReactor#validate

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5d4113f2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 15a2254..1e9a98f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
   <parent>
     <artifactId>project</artifactId>
     <groupId>org.apache.httpcomponents</groupId>
-    <version>4.1.1</version>
+    <version>5</version>
     <relativePath>../project/pom.xml</relativePath>
   </parent>
   <modelVersion>4.0.0</modelVersion>


[08/35] httpcomponents-core git commit: HTTPCORE-259: inaccurate exception message at ResponseContent

Posted by ol...@apache.org.
HTTPCORE-259: inaccurate exception message at ResponseContent

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1134572 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 5fff28bd7e54c247fe52fe6dee76429e1d895d02
Parents: ee0f377
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat Jun 11 11:21:59 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Jun 11 11:21:59 2011 +0000

----------------------------------------------------------------------
 .../src/main/java/org/apache/http/protocol/ResponseContent.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5fff28bd/httpcore/src/main/java/org/apache/http/protocol/ResponseContent.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/protocol/ResponseContent.java b/httpcore/src/main/java/org/apache/http/protocol/ResponseContent.java
index 26b70ba..2e4beca 100644
--- a/httpcore/src/main/java/org/apache/http/protocol/ResponseContent.java
+++ b/httpcore/src/main/java/org/apache/http/protocol/ResponseContent.java
@@ -57,7 +57,7 @@ public class ResponseContent implements HttpResponseInterceptor {
     public void process(final HttpResponse response, final HttpContext context)
             throws HttpException, IOException {
         if (response == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
+            throw new IllegalArgumentException("HTTP response may not be null");
         }
         if (response.containsHeader(HTTP.TRANSFER_ENCODING)) {
             throw new ProtocolException("Transfer-encoding header already present");


[25/35] httpcomponents-core git commit: HTTPCORE-281: ResponseConnControl protocol interceptor does not correctly populate connection persistence control headers when sending a HTTP/1.1 response message in response to a HTTP/1.0 request message (merged f

Posted by ol...@apache.org.
HTTPCORE-281: ResponseConnControl protocol interceptor does not correctly populate connection persistence control headers when sending a HTTP/1.1 response message in response to a HTTP/1.0 request message (merged from trunk)
Contributed by William R. Speirs <bill.speirs at gmail.com>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1204996 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 24802042ed42554b1860977317a0f79e30626f5a
Parents: a32882c
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Tue Nov 22 13:55:49 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Nov 22 13:55:49 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                                    |  5 +++++
 .../apache/http/protocol/ResponseConnControl.java    |  4 +++-
 .../http/protocol/TestStandardInterceptors.java      | 15 +++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/24802042/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 38bad2b..a5148fb 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,11 @@
 Changes since 4.1.3
 -------------------
 
+* [HTTPCORE-281] ResponseConnControl protocol interceptor does not correctly populate connection
+  persistence control headers when sending a HTTP/1.1 response message in response to a HTTP/1.0 
+  request message.
+  Contributed by William R. Speirs <bill.speirs at gmail.com>
+
 * [HTTPCORE-282] The default value of the internal event mask of newly created non-blocking I/O 
   is not correctly initialized, which causes the READ interest bit to get cleared in the interest 
   op queuing mode unless the event mask is explicitly reset.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/24802042/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java b/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
index 7541a09..ad738a9 100644
--- a/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
+++ b/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
@@ -84,13 +84,15 @@ public class ResponseConnControl implements HttpResponseInterceptor {
                 return;
             }
         }
-        // Drop connection if requested by the client
+        // Drop connection if requested by the client or request was <= 1.0
         HttpRequest request = (HttpRequest)
             context.getAttribute(ExecutionContext.HTTP_REQUEST);
         if (request != null) {
             Header header = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
             if (header != null) {
                 response.setHeader(HTTP.CONN_DIRECTIVE, header.getValue());
+            } else if (request.getProtocolVersion().lessEquals(HttpVersion.HTTP_1_0)) {
+                response.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/24802042/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java b/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
index b35382b..4c5412f 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
@@ -543,6 +543,21 @@ public class TestStandardInterceptors extends TestCase {
         assertNull(header);
     }
 
+    public void testResponseConnControl10Client11Response() throws Exception {
+        HttpContext context = new BasicHttpContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_0);
+        context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
+
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        StringEntity entity = new StringEntity("whatever");
+        response.setEntity(entity);
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNotNull(header);
+        assertEquals(HTTP.CONN_CLOSE, header.getValue());
+    }
+
     public void testResponseConnControlStatusCode() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");


[28/35] httpcomponents-core git commit: Merged HTTPCORE-257 from trunk

Posted by ol...@apache.org.
Merged HTTPCORE-257 from trunk

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1215569 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: a92bd33a59d3e208438cb99becc71a257a0c5f14
Parents: ab58c97
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat Dec 17 20:59:41 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Dec 17 20:59:41 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |   8 +-
 .../impl/DefaultConnectionReuseStrategy.java    |  35 +--
 .../entity/StrictContentLengthStrategy.java     |   3 +
 .../TestDefaultConnectionReuseStrategy.java     | 237 +++++--------------
 .../entity/TestStrictContentLengthStrategy.java |  11 +
 5 files changed, 91 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a92bd33a/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index cf2dadf..8a3e3b9 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,10 @@
 Changes since 4.1.3
 -------------------
 
+* [HTTPCORE-257] Fixed incorrect results produced by DefaultConnectionReuseStrategy when handling 
+  response messages whose content entity has been decoded or modified by a protocol interceptor. 
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-283] Workaround for a bug causing termination of the I/O reactor in case of exception 
   thrown by NHttpServiceHandler#requestReceived or NHttpClientHandler#responseReceived
   methods. A more comprehensive fix for the bug applied to the (4.2 branch).
@@ -47,10 +51,6 @@ recommendations in javadocs.
   truncation when message content is chunk coded and the connection is closed on the opposite end. 
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 
-* [HTTPCORE-257] Fixed incorrect results produced by DefaultConnectionReuseStrategy when handling 
-  response messages whose content entity has been decoded or modified by a protocol interceptor. 
-  Contributed by Oleg Kalnichevski <olegk at apache.org>
-
 Release 4.1.1
 -------------------
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a92bd33a/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java b/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
index 47828f6..865da5b 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
@@ -28,16 +28,14 @@
 package org.apache.http.impl;
 
 import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpConnection;
+import org.apache.http.Header;
 import org.apache.http.HeaderIterator;
-import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
 import org.apache.http.ParseException;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.TokenIterator;
 import org.apache.http.message.BasicTokenIterator;
 
@@ -77,25 +75,28 @@ public class DefaultConnectionReuseStrategy implements ConnectionReuseStrategy {
                 ("HTTP context may not be null.");
         }
 
-        HttpConnection conn = (HttpConnection)
-            context.getAttribute(ExecutionContext.HTTP_CONNECTION);
-
-        if (conn != null && !conn.isOpen())
-            return false;
-        // do NOT check for stale connection, that is an expensive operation
-
         // Check for a self-terminating entity. If the end of the entity will
         // be indicated by closing the connection, there is no keep-alive.
-        HttpEntity entity = response.getEntity();
         ProtocolVersion ver = response.getStatusLine().getProtocolVersion();
-        if (entity != null) {
-            if (entity.getContentLength() < 0) {
-                if (!entity.isChunked() ||
-                    ver.lessEquals(HttpVersion.HTTP_1_0)) {
-                    // if the content length is not known and is not chunk
-                    // encoded, the connection cannot be reused
+        Header teh = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
+        if (teh != null) {
+            if (!HTTP.CHUNK_CODING.equalsIgnoreCase(teh.getValue())) {
+                return false;
+            }
+        } else {
+            Header[] clhs = response.getHeaders(HTTP.CONTENT_LEN);
+            // Do not reuse if not properly content-length delimited
+            if (clhs == null || clhs.length != 1) {
+                return false;
+            }
+            Header clh = clhs[0];
+            try {
+                int contentLen = Integer.parseInt(clh.getValue());
+                if (contentLen < 0) {
                     return false;
                 }
+            } catch (NumberFormatException ex) {
+                return false;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a92bd33a/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java b/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
index 18f772e..8575d3d 100644
--- a/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
+++ b/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
@@ -79,6 +79,9 @@ public class StrictContentLengthStrategy implements ContentLengthStrategy {
             String s = contentLengthHeader.getValue();
             try {
                 long len = Long.parseLong(s);
+                if (len < 0) {
+                    throw new ProtocolException("Negative content length: " + s);
+                }
                 return len;
             } catch (NumberFormatException e) {
                 throw new ProtocolException("Invalid content length: " + s);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a92bd33a/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java b/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
index a52ff5f..3cc3ba5 100644
--- a/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
+++ b/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
@@ -30,23 +30,14 @@ package org.apache.http.impl;
 import junit.framework.TestCase;
 
 import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpConnection;
-import org.apache.http.HttpConnectionMetrics;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
-import org.apache.http.StatusLine;
-import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
 import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
 
 public class TestDefaultConnectionReuseStrategy extends TestCase {
 
-    /** A mock connection that is open and not stale. */
-    private HttpConnection mockConnection;
-
     /** HTTP context. */
     private HttpContext context;
 
@@ -60,15 +51,8 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
     }
 
     public void setUp() {
-        // open and not stale is required for most of the tests here
-        mockConnection = new MockConnection(true, false);
         reuseStrategy = new DefaultConnectionReuseStrategy();
         context = new BasicHttpContext(null);
-        context.setAttribute(ExecutionContext.HTTP_CONNECTION, mockConnection);
-    }
-
-    public void tearDown() {
-        mockConnection = null;
     }
 
     // ------------------------------------------------------- TestCase Methods
@@ -86,66 +70,36 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
     }
 
     public void testIllegalContextArg() throws Exception {
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", false, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         try {
             reuseStrategy.keepAlive(response, null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
+
     }
 
     public void testNoContentLengthResponseHttp1_0() throws Exception {
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_0, 200, "OK", false, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
 
         assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
     public void testNoContentLengthResponseHttp1_1() throws Exception {
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", false, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
 
         assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
     public void testChunkedContent() throws Exception {
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
-
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
-    public void testClosedConnection() throws Exception {
-
-        // based on testChunkedContent which is known to return true
-        // the difference is in the mock connection passed here
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
-
-        HttpConnection mockonn = new MockConnection(false, false);
-        context.setAttribute(ExecutionContext.HTTP_CONNECTION, mockonn);
-        assertFalse("closed connection should not be kept alive",
-                    reuseStrategy.keepAlive(response, context));
-    }
-
-    public void testStaleConnection() throws Exception {
-
-        // based on testChunkedContent which is known to return true
-        // the difference is in the mock connection passed here
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
-
-        HttpConnection mockonn = new MockConnection(true, true);
-        context.setAttribute(ExecutionContext.HTTP_CONNECTION, mockonn);
-        assertTrue("stale connection should not be detected",
-                    reuseStrategy.keepAlive(response, context));
-    }
-
     public void testIgnoreInvalidKeepAlive() throws Exception {
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_0, 200, "OK", false, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
         response.addHeader("Connection", "keep-alive");
 
         assertFalse(reuseStrategy.keepAlive(response, context));
@@ -153,8 +107,8 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testExplicitClose() throws Exception {
         // Use HTTP 1.1
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "close");
 
         assertFalse(reuseStrategy.keepAlive(response, context));
@@ -162,37 +116,36 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testExplicitKeepAlive() throws Exception {
         // Use HTTP 1.0
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_0, 200, "OK", false, 10);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
+        response.addHeader("Content-Length", "10");
         response.addHeader("Connection", "keep-alive");
 
         assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
     public void testHTTP10Default() throws Exception {
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_0, 200, "OK");
-
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
+        response.addHeader("Content-Length", "10");
         assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
     public void testHTTP11Default() throws Exception {
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Content-Length", "10");
         assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
     public void testFutureHTTP() throws Exception {
-        HttpResponse response =
-            createResponse(new HttpVersion(3, 45), 200, "OK");
+        HttpResponse response = new BasicHttpResponse(new HttpVersion(3, 45), 200, "OK");
+        response.addHeader("Content-Length", "10");
 
         assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
     public void testBrokenConnectionDirective1() throws Exception {
         // Use HTTP 1.0
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_0, 200, "OK");
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
+        response.addHeader("Content-Length", "10");
         response.addHeader("Connection", "keep--alive");
 
         assertFalse(reuseStrategy.keepAlive(response, context));
@@ -200,8 +153,8 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testBrokenConnectionDirective2() throws Exception {
         // Use HTTP 1.0
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_0, 200, "OK");
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
+        response.addHeader("Content-Length", "10");
         response.addHeader("Connection", null);
 
         assertFalse(reuseStrategy.keepAlive(response, context));
@@ -209,8 +162,8 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testConnectionTokens1() throws Exception {
         // Use HTTP 1.1
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "yadda, cLOSe, dumdy");
 
         assertFalse(reuseStrategy.keepAlive(response, context));
@@ -218,8 +171,8 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testConnectionTokens2() throws Exception {
         // Use HTTP 1.1
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "yadda, kEEP-alive, dumdy");
 
         assertTrue(reuseStrategy.keepAlive(response, context));
@@ -227,8 +180,8 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testConnectionTokens3() throws Exception {
         // Use HTTP 1.1
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "yadda, keep-alive, close, dumdy");
 
         assertFalse(reuseStrategy.keepAlive(response, context));
@@ -236,22 +189,20 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testConnectionTokens4() throws Exception {
         // Use HTTP 1.1
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "yadda, close, dumdy");
         response.addHeader("Proxy-Connection", "keep-alive");
-
         // Connection takes precedence over Proxy-Connection
         assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
     public void testConnectionTokens5() throws Exception {
         // Use HTTP 1.1
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "yadda, dumdy");
         response.addHeader("Proxy-Connection", "close");
-
         // Connection takes precedence over Proxy-Connection,
         // even if it doesn't contain a recognized token.
         // Default for HTTP/1.1 is to keep alive.
@@ -260,11 +211,10 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testConnectionTokens6() throws Exception {
         // Use HTTP 1.1
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "");
         response.addHeader("Proxy-Connection", "close");
-
         // Connection takes precedence over Proxy-Connection,
         // even if it is empty. Default for HTTP/1.1 is to keep alive.
         assertTrue(reuseStrategy.keepAlive(response, context));
@@ -272,110 +222,33 @@ public class TestDefaultConnectionReuseStrategy extends TestCase {
 
     public void testConnectionTokensInvalid() throws Exception {
         // Use HTTP 1.1
-        HttpResponse response =
-            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "keep-alive=true");
-
         assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    public void testMultipleContentLength() throws Exception {
+        // Use HTTP 1.1
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Content-Length", "10");
+        response.addHeader("Content-Length", "11");
+        assertFalse(reuseStrategy.keepAlive(response, context));
+    }
 
-    /**
-     * Creates a response without an entity.
-     *
-     * @param version   the HTTP version
-     * @param status    the status code
-     * @param message   the status message
-     *
-     * @return  a response with the argument attributes, but no headers
-     */
-    private final static HttpResponse createResponse(HttpVersion version,
-                                                     int status,
-                                                     String message) {
-
-        StatusLine statusline = new BasicStatusLine(version, status, message);
-        HttpResponse response = new BasicHttpResponse(statusline);
-
-        return response;
-
-    } // createResponse/empty
-
-
-    /**
-     * Creates a response with an entity.
-     *
-     * @param version   the HTTP version
-     * @param status    the status code
-     * @param message   the status message
-     * @param chunked   whether the entity should indicate chunked encoding
-     * @param length    the content length to be indicated by the entity
-     *
-     * @return  a response with the argument attributes, but no headers
-     */
-    private final static HttpResponse createResponse(HttpVersion version,
-                                                     int status,
-                                                     String message,
-                                                     boolean chunked,
-                                                     int length) {
-
-        BasicHttpEntity entity = new BasicHttpEntity();
-        entity.setChunked(chunked);
-        entity.setContentLength(length);
-        HttpResponse response = createResponse(version, status, message);
-        response.setEntity(entity);
-
-        return response;
-
-    } // createResponse/entity
-
-
-    /**
-     * A mock connection.
-     * This is neither client nor server connection, since the default
-     * strategy is agnostic. It does not allow modification of it's state,
-     * since the strategy is supposed to decide about keep-alive, but not
-     * to modify the connection's state.
-     */
-    private final static class MockConnection implements HttpConnection {
-
-        private boolean iAmOpen;
-        private boolean iAmStale;
-
-        public MockConnection(boolean open, boolean stale) {
-            iAmOpen = open;
-            iAmStale = stale;
-        }
-
-        public final boolean isOpen() {
-            return iAmOpen;
-        }
-
-        public void setSocketTimeout(int timeout) {
-        }
-
-        public int getSocketTimeout() {
-            return -1;
-        }
-
-        public final boolean isStale() {
-            return iAmStale;
-        }
-
-        public final void close() {
-            throw new UnsupportedOperationException
-                ("connection state must not be modified");
-        }
-
-        public final void shutdown() {
-            throw new UnsupportedOperationException
-                ("connection state must not be modified");
-        }
-
-        public HttpConnectionMetrics getMetrics() {
-            return null;
-        }
+    public void testInvalidContentLength() throws Exception {
+        // Use HTTP 1.1
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Content-Length", "crap");
+        assertFalse(reuseStrategy.keepAlive(response, context));
+    }
 
-    } // class MockConnection
+    public void testInvalidNegativeContentLength() throws Exception {
+        // Use HTTP 1.1
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
+        response.addHeader("Content-Length", "-10");
+        assertFalse(reuseStrategy.keepAlive(response, context));
+    }
 
-} // class TestDefaultConnectionReuseStrategy
+}
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a92bd33a/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java b/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java
index a853ee4..7868e76 100644
--- a/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java
+++ b/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java
@@ -97,7 +97,18 @@ public class TestStrictContentLengthStrategy extends TestCase {
         ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
         message.addHeader("Content-Length", "whatever");
+        try {
+            lenStrategy.determineLength(message);
+            fail("ProtocolException should have been thrown");
+        } catch (ProtocolException ex) {
+            // expected
+        }
+    }
 
+    public void testEntityWithNegativeContentLength() throws Exception {
+        ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
+        HttpMessage message = new HttpMessageMockup();
+        message.addHeader("Content-Length", "-10");
         try {
             lenStrategy.determineLength(message);
             fail("ProtocolException should have been thrown");


[24/35] httpcomponents-core git commit: HTTPCORE-282: The default value of the internal event mask of newly created non-blocking I/O is not correctly initialized, which causes the READ interest bit to get cleared in the interest op queuing mode unless th

Posted by ol...@apache.org.
HTTPCORE-282: The default value of the internal event mask of newly created non-blocking I/O is not correctly initialized, which causes the READ interest bit to get cleared in the interest op queuing mode unless the event mask is explicitly reset

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1204950 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: a32882c5f09512045f0909b8803d8866cde9d978
Parents: 85263c2
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Tue Nov 22 12:20:36 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Nov 22 12:20:36 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                                            | 8 ++++----
 .../java/org/apache/http/impl/nio/NHttpConnectionBase.java   | 1 -
 .../java/org/apache/http/impl/nio/reactor/IOSessionImpl.java | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a32882c5/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index e7d7526..38bad2b 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,10 +1,10 @@
 Changes since 4.1.3
 -------------------
 
-* [HTTPCORE-282] Newly created non-blocking I/O sessions to have READ interest op bit cleared 
-  per default due to a regression introduced in release 4.1.1. This has a side effect on client
-  side non-blocking connections when running in the interest op queuing mode.
-  Contributed by Sadeep Jayasumana <sadeep at wso2.com> 
+* [HTTPCORE-282] The default value of the internal event mask of newly created non-blocking I/O 
+  is not correctly initialized, which causes the READ interest bit to get cleared in the interest 
+  op queuing mode unless the event mask is explicitly reset.
+  Contributed by Sadeep Jayasumana <sadeep at wso2.com> and Oleg Kalnichevski <olegk at apache.org>
 
 * [HTTPCORE-268] Handle runtime exceptions thrown by SSLEngine.
   Contributed by Oleg Kalnichevski <olegk at apache.org>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a32882c5/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index 980b883..4e2b192 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -156,7 +156,6 @@ public class NHttpConnectionBase
         this.session = session;
         this.context = new SessionHttpContext(this.session);
         this.session.setBufferStatus(this);
-        this.session.setEvent(EventMask.READ);
         this.remote = this.session.getRemoteAddress();
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a32882c5/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index 2c3f802..277db9a 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -87,7 +87,7 @@ public class IOSessionImpl implements IOSession {
         this.interestOpsCallback = interestOpsCallback;
         this.sessionClosedCallback = sessionClosedCallback;
         this.attributes = Collections.synchronizedMap(new HashMap<String, Object>());
-        this.currentEventMask = 0;
+        this.currentEventMask = key.interestOps();
         this.socketTimeout = 0;
         this.status = ACTIVE;
         long now = System.currentTimeMillis();


[22/35] httpcomponents-core git commit: HTTPCORE-268: handle runtime exceptions thrown by SSLEngine (merged from trunk)

Posted by ol...@apache.org.
HTTPCORE-268: handle runtime exceptions thrown by SSLEngine (merged from trunk)

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1157115 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 76ed6f59868ede6b9f3faf1ddb5bdf6be6cb5825
Parents: cc013c3
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri Aug 12 14:13:52 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri Aug 12 14:13:52 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  6 +++
 .../http/impl/nio/reactor/SSLIOSession.java     | 53 +++++++++++++++++---
 2 files changed, 52 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/76ed6f59/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index fe0f1f9..f59bd02 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,3 +1,9 @@
+Changes since 4.1.3
+-------------------
+
+* [HTTPCORE-268] Handle runtime exceptions thrown by SSLEngine.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 Release 4.1.3
 -------------------
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/76ed6f59/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
index 4cff03c..d7324c9 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
@@ -142,6 +142,46 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
         doHandshake();
     }
 
+    // A works-around for exception handling craziness in Sun/Oracle's SSLEngine
+    // implementation.
+    //
+    // sun.security.pkcs11.wrapper.PKCS11Exception is re-thrown as
+    // plain RuntimeException in sun.security.ssl.Handshaker#checkThrown
+    private SSLException convert(final RuntimeException ex) throws SSLException {
+		Throwable cause = ex.getCause();
+		if (cause == null) {
+			cause = ex;
+		}
+		return new SSLException(cause);
+    }
+
+    private SSLEngineResult doWrap(final ByteBuffer src, final ByteBuffer dst) throws SSLException {
+    	try {
+        	return this.sslEngine.wrap(src, dst);
+    	} catch (RuntimeException ex) {
+    		throw convert(ex);
+    	}
+    }
+
+    private SSLEngineResult doUnwrap(final ByteBuffer src, final ByteBuffer dst) throws SSLException {
+    	try {
+        	return this.sslEngine.unwrap(src, dst);
+    	} catch (RuntimeException ex) {
+    		throw convert(ex);
+    	}
+    }
+
+    private void doRunTask() throws SSLException {
+    	try {
+            Runnable r = this.sslEngine.getDelegatedTask();
+            if (r != null) {
+            	r.run();
+            }
+    	} catch (RuntimeException ex) {
+    		throw convert(ex);
+    	}
+    }
+
     private void doHandshake() throws SSLException {
         boolean handshaking = true;
 
@@ -151,7 +191,7 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
             case NEED_WRAP:
                 // Generate outgoing handshake data
                 this.outPlain.flip();
-                result = this.sslEngine.wrap(this.outPlain, this.outEncrypted);
+                result = doWrap(this.outPlain, this.outEncrypted);
                 this.outPlain.compact();
                 if (result.getStatus() != Status.OK) {
                     handshaking = false;
@@ -160,15 +200,14 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
             case NEED_UNWRAP:
                 // Process incoming handshake data
                 this.inEncrypted.flip();
-                result = this.sslEngine.unwrap(this.inEncrypted, this.inPlain);
+                result = doUnwrap(this.inEncrypted, this.inPlain);
                 this.inEncrypted.compact();
                 if (result.getStatus() != Status.OK) {
                     handshaking = false;
                 }
                 break;
             case NEED_TASK:
-                Runnable r = this.sslEngine.getDelegatedTask();
-                r.run();
+            	doRunTask();
                 break;
             case NOT_HANDSHAKING:
                 handshaking = false;
@@ -246,7 +285,7 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
         SSLEngineResult.Status opStatus = Status.OK;
         while (this.inEncrypted.position() > 0 && opStatus == Status.OK) {
             this.inEncrypted.flip();
-            SSLEngineResult result = this.sslEngine.unwrap(this.inEncrypted, this.inPlain);
+            SSLEngineResult result = doUnwrap(this.inEncrypted, this.inPlain);
             this.inEncrypted.compact();
 
             opStatus = result.getStatus();
@@ -302,11 +341,11 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
         }
         if (this.outPlain.position() > 0) {
             this.outPlain.flip();
-            this.sslEngine.wrap(this.outPlain, this.outEncrypted);
+            doWrap(this.outPlain, this.outEncrypted);
             this.outPlain.compact();
         }
         if (this.outPlain.position() == 0) {
-            SSLEngineResult result = this.sslEngine.wrap(src, this.outEncrypted);
+            SSLEngineResult result = doWrap(src, this.outEncrypted);
             if (result.getStatus() == Status.CLOSED) {
                 this.status = CLOSED;
             }


[34/35] httpcomponents-core git commit: HTTPCORE-296: server side connections (both blocking and non-blocking) to reject entity enclosing requests without Content-Length and Transfer-Encoding headers as invalid

Posted by ol...@apache.org.
HTTPCORE-296: server side connections (both blocking and non-blocking) to reject entity enclosing requests without Content-Length and Transfer-Encoding headers as invalid

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1302139 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: e45e29f2a8acadb94eca663a3c4c4403736fbc0a
Parents: c00ffe2
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Mar 18 15:10:58 2012 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Mar 18 15:10:58 2012 +0000

----------------------------------------------------------------------
 .../impl/nio/DefaultNHttpServerConnection.java  |   8 +
 .../http/impl/nio/NHttpConnectionBase.java      |  35 +++-
 .../http/impl/AbstractHttpServerConnection.java |   4 +-
 .../DisallowIdentityContentLengthStrategy.java  |  58 +++++++
 .../java/org/apache/http/mockup/HttpClient.java |  16 +-
 .../protocol/TestHttpServiceAndExecutor.java    | 164 +++++++++++++++++++
 6 files changed, 276 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e45e29f2/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index 2c0fe25..f180954 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -37,6 +37,9 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestFactory;
 import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentLengthStrategy;
+import org.apache.http.impl.entity.DisallowIdentityContentLengthStrategy;
+import org.apache.http.impl.entity.LaxContentLengthStrategy;
 import org.apache.http.impl.nio.codecs.DefaultHttpRequestParser;
 import org.apache.http.impl.nio.codecs.DefaultHttpResponseWriter;
 import org.apache.http.nio.NHttpMessageParser;
@@ -92,6 +95,11 @@ public class DefaultNHttpServerConnection
         this.responseWriter = createResponseWriter(this.outbuf, params);
     }
 
+    @Override
+    protected ContentLengthStrategy createIncomingContentStrategy() {
+        return new DisallowIdentityContentLengthStrategy(new LaxContentLengthStrategy());
+    }
+
     /**
      * Creates an instance of {@link NHttpMessageParser} to be used
      * by this connection for parsing incoming {@link HttpRequest} messages.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e45e29f2/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index 4e2b192..a1f6b91 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -139,8 +139,8 @@ public class NHttpConnectionBase
         this.inbuf = new SessionInputBufferImpl(buffersize, linebuffersize, allocator, params);
         this.outbuf = new SessionOutputBufferImpl(buffersize, linebuffersize, allocator, params);
 
-        this.incomingContentStrategy = new LaxContentLengthStrategy();
-        this.outgoingContentStrategy = new StrictContentLengthStrategy();
+        this.incomingContentStrategy = createIncomingContentStrategy();
+        this.outgoingContentStrategy = createOutgoingContentStrategy();
 
         this.inTransportMetrics = createTransportMetrics();
         this.outTransportMetrics = createTransportMetrics();
@@ -160,6 +160,37 @@ public class NHttpConnectionBase
     }
 
     /**
+<<<<<<< HEAD
+=======
+     * Binds the connection to a different {@link IOSession}. This may be necessary
+     * when the underlying I/O session gets upgraded with SSL/TLS encryption.
+     *
+     * @since 4.2
+     */
+    protected void bind(final IOSession session) {
+        if (session == null) {
+            throw new IllegalArgumentException("I/O session may not be null");
+        }
+        this.session.setBufferStatus(null);
+        setSession(session);
+    }
+
+    /**
+     * @since 4.2
+     */
+    protected ContentLengthStrategy createIncomingContentStrategy() {
+        return new LaxContentLengthStrategy();
+    }
+
+    /**
+     * @since 4.2
+     */
+    protected ContentLengthStrategy createOutgoingContentStrategy() {
+        return new StrictContentLengthStrategy();
+    }
+
+    /**
+>>>>>>> 74acee1... HTTPCORE-296: server side connections (both blocking and non-blocking) can now handle entity enclosing requests without Content-Length and Transfer-Encoding headers
      * @since 4.1
      */
     protected HttpTransportMetricsImpl createTransportMetrics() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e45e29f2/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java b/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
index eb7de0e..322c946 100644
--- a/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
@@ -38,6 +38,7 @@ import org.apache.http.HttpRequestFactory;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpServerConnection;
 import org.apache.http.entity.ContentLengthStrategy;
+import org.apache.http.impl.entity.DisallowIdentityContentLengthStrategy;
 import org.apache.http.impl.entity.EntityDeserializer;
 import org.apache.http.impl.entity.EntitySerializer;
 import org.apache.http.impl.entity.LaxContentLengthStrategy;
@@ -114,7 +115,8 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
      * @return HTTP entity deserializer
      */
     protected EntityDeserializer createEntityDeserializer() {
-        return new EntityDeserializer(new LaxContentLengthStrategy());
+        return new EntityDeserializer(new DisallowIdentityContentLengthStrategy(
+                new LaxContentLengthStrategy()));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e45e29f2/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java b/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java
new file mode 100644
index 0000000..8a5ba49
--- /dev/null
+++ b/httpcore/src/main/java/org/apache/http/impl/entity/DisallowIdentityContentLengthStrategy.java
@@ -0,0 +1,58 @@
+/*
+ * ====================================================================
+ * 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.impl.entity;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpMessage;
+import org.apache.http.ProtocolException;
+import org.apache.http.entity.ContentLengthStrategy;
+
+/**
+ * Decorator for  {@link ContentLengthStrategy} implementations that disallows the use of 
+ * identity transfer encoding. 
+ *
+ * @since 4.2
+ */
+public class DisallowIdentityContentLengthStrategy implements ContentLengthStrategy {
+
+    private final ContentLengthStrategy contentLengthStrategy;
+    
+    public DisallowIdentityContentLengthStrategy(final ContentLengthStrategy contentLengthStrategy) {
+        super();
+        this.contentLengthStrategy = contentLengthStrategy;
+    }
+
+    public long determineLength(final HttpMessage message) throws HttpException {
+        long result = this.contentLengthStrategy.determineLength(message);
+        if (result == ContentLengthStrategy.IDENTITY) {
+            throw new ProtocolException("Identity transfer encoding cannot be used");
+        }
+        return result;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e45e29f2/httpcore/src/test/java/org/apache/http/mockup/HttpClient.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/mockup/HttpClient.java b/httpcore/src/test/java/org/apache/http/mockup/HttpClient.java
index cd882f6..353e3e3 100644
--- a/httpcore/src/test/java/org/apache/http/mockup/HttpClient.java
+++ b/httpcore/src/test/java/org/apache/http/mockup/HttpClient.java
@@ -63,25 +63,29 @@ public class HttpClient {
     private final ConnectionReuseStrategy connStrategy;
     private final HttpContext context;
 
-    public HttpClient() {
+    public HttpClient(final HttpProcessor httpproc) {
         super();
+        this.httpproc = httpproc;
+        this.connStrategy = new DefaultConnectionReuseStrategy();
         this.params = new SyncBasicHttpParams();
         this.params
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1)
             .setParameter(CoreProtocolPNames.USER_AGENT, "TEST-CLIENT/1.1");
-        this.httpproc = new ImmutableHttpProcessor(
+        this.httpexecutor = new HttpRequestExecutor();
+        this.context = new BasicHttpContext();
+    }
+
+    public HttpClient() {
+        this(new ImmutableHttpProcessor(
                 new HttpRequestInterceptor[] {
                         new RequestContent(),
                         new RequestTargetHost(),
                         new RequestConnControl(),
                         new RequestUserAgent(),
                         new RequestExpectContinue()
-                });
-        this.httpexecutor = new HttpRequestExecutor();
-        this.connStrategy = new DefaultConnectionReuseStrategy();
-        this.context = new BasicHttpContext();
+                }));
     }
 
     public HttpParams getParams() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e45e29f2/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java b/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
index 5eb1330..660a10a 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
@@ -46,6 +46,7 @@ import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
@@ -58,6 +59,15 @@ import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.mockup.HttpClient;
 import org.apache.http.mockup.HttpServer;
 import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpExpectationVerifier;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.http.protocol.ImmutableHttpProcessor;
+import org.apache.http.protocol.RequestConnControl;
+import org.apache.http.protocol.RequestExpectContinue;
+import org.apache.http.protocol.RequestTargetHost;
+import org.apache.http.protocol.RequestUserAgent;
 import org.apache.http.util.EncodingUtils;
 import org.apache.http.util.EntityUtils;
 
@@ -753,4 +763,158 @@ public class TestHttpServiceAndExecutor extends TestCase {
         }
     }
 
+    public void testHttpPostNoEntity() throws Exception {
+        this.server.registerHandler("*", new HttpRequestHandler() {
+
+            public void handle(
+                    final HttpRequest request,
+                    final HttpResponse response,
+                    final HttpContext context) throws HttpException, IOException {
+
+                if (request instanceof HttpEntityEnclosingRequest) {
+                    HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity();
+                    byte[] data = EntityUtils.toByteArray(incoming);
+                    ByteArrayEntity outgoing = new ByteArrayEntity(data);
+                    response.setEntity(outgoing);
+                } else {
+                    StringEntity outgoing = new StringEntity("No content");
+                    response.setEntity(outgoing);
+                }
+            }
+
+        });
+
+        this.server.start();
+
+        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        HttpHost host = new HttpHost("localhost", this.server.getPort());
+
+        try {
+            if (!conn.isOpen()) {
+                Socket socket = new Socket(host.getHostName(), host.getPort());
+                conn.bind(socket, this.client.getParams());
+            }
+
+            BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
+            post.setEntity(null);
+
+            HttpResponse response = this.client.execute(post, host, conn);
+            assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+            byte[] received = EntityUtils.toByteArray(response.getEntity());
+            assertEquals(0, received.length);
+        } finally {
+            conn.close();
+            this.server.shutdown();
+        }
+    }
+
+    public void testHttpPostNoContentLength() throws Exception {
+        this.server.registerHandler("*", new HttpRequestHandler() {
+
+            public void handle(
+                    final HttpRequest request,
+                    final HttpResponse response,
+                    final HttpContext context) throws HttpException, IOException {
+
+                if (request instanceof HttpEntityEnclosingRequest) {
+                    HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity();
+                    byte[] data = EntityUtils.toByteArray(incoming);
+                    ByteArrayEntity outgoing = new ByteArrayEntity(data);
+                    response.setEntity(outgoing);
+                } else {
+                    StringEntity outgoing = new StringEntity("No content");
+                    response.setEntity(outgoing);
+                }
+            }
+
+        });
+
+        this.server.start();
+
+        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        HttpHost host = new HttpHost("localhost", this.server.getPort());
+
+        try {
+            if (!conn.isOpen()) {
+                Socket socket = new Socket(host.getHostName(), host.getPort());
+                conn.bind(socket, this.client.getParams());
+            }
+
+            BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
+            post.setEntity(null);
+
+            this.client = new HttpClient(new ImmutableHttpProcessor(
+                    new HttpRequestInterceptor[] {
+                            new RequestTargetHost(),
+                            new RequestConnControl(),
+                            new RequestUserAgent(),
+                            new RequestExpectContinue() }));
+            
+            HttpResponse response = this.client.execute(post, host, conn);
+            assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
+        } finally {
+            conn.close();
+            this.server.shutdown();
+        }
+    }
+
+    public void testHttpPostIdentity() throws Exception {
+        this.server.registerHandler("*", new HttpRequestHandler() {
+
+            public void handle(
+                    final HttpRequest request,
+                    final HttpResponse response,
+                    final HttpContext context) throws HttpException, IOException {
+
+                if (request instanceof HttpEntityEnclosingRequest) {
+                    HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity();
+                    byte[] data = EntityUtils.toByteArray(incoming);
+                    ByteArrayEntity outgoing = new ByteArrayEntity(data);
+                    response.setEntity(outgoing);
+                } else {
+                    StringEntity outgoing = new StringEntity("No content");
+                    response.setEntity(outgoing);
+                }
+            }
+
+        });
+
+        this.server.start();
+
+        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
+        HttpHost host = new HttpHost("localhost", this.server.getPort());
+
+        try {
+            if (!conn.isOpen()) {
+                Socket socket = new Socket(host.getHostName(), host.getPort());
+                conn.bind(socket, this.client.getParams());
+            }
+
+            BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
+            post.setEntity(null);
+
+            this.client = new HttpClient(new ImmutableHttpProcessor(
+                    new HttpRequestInterceptor[] {
+                            new HttpRequestInterceptor() {
+                                
+                                public void process(
+                                        final HttpRequest request, 
+                                        final HttpContext context) throws HttpException, IOException {
+                                    request.addHeader(HTTP.TRANSFER_ENCODING, "identity");
+                                }
+
+                            },
+                            new RequestTargetHost(),
+                            new RequestConnControl(),
+                            new RequestUserAgent(),
+                            new RequestExpectContinue() }));
+            
+            HttpResponse response = this.client.execute(post, host, conn);
+            assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
+        } finally {
+            conn.close();
+            this.server.shutdown();
+        }
+    }
+
 }


[13/35] httpcomponents-core git commit: expose iosession creation, last read, write and access times as public

Posted by ol...@apache.org.
expose iosession creation, last read, write and access times as public


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1144157 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 1caa7be34d9806af8a7dd6c8ab49e7386b71d4a6
Parents: 42868c5
Author: Asankha Chamath Perera <as...@apache.org>
Authored: Fri Jul 8 05:07:11 2011 +0000
Committer: Asankha Chamath Perera <as...@apache.org>
Committed: Fri Jul 8 05:07:11 2011 +0000

----------------------------------------------------------------------
 .../java/org/apache/http/impl/nio/reactor/IOSessionImpl.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/1caa7be3/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index 30b3e70..7e63cde 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -263,19 +263,19 @@ public class IOSessionImpl implements IOSession {
         this.attributes.put(name, obj);
     }
 
-    synchronized long getStartedTime() {
+    public synchronized long getStartedTime() {
         return this.startedTime;
     }
 
-    synchronized long getLastReadTime() {
+    public synchronized long getLastReadTime() {
         return this.lastReadTime;
     }
 
-    synchronized long getLastWriteTime() {
+    public synchronized long getLastWriteTime() {
         return this.lastWriteTime;
     }
 
-    synchronized long getLastAccessTime() {
+    public synchronized long getLastAccessTime() {
         return this.lastAccessTime;
     }
 


[05/35] httpcomponents-core git commit: In case of an unexpected end of stream condition (the peer closed connection prematurely) truncated Content-Length delimited message bodies to cause an I/O (merged from trunk)

Posted by ol...@apache.org.
In case of an unexpected end of stream condition (the peer closed connection
prematurely) truncated Content-Length delimited message bodies to cause an I/O (merged from trunk)

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1102665 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: ef786ef03d47670290d85f4453ae3a00b320ab9c
Parents: 26632ee
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri May 13 11:04:18 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri May 13 11:04:18 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  7 +++
 .../impl/nio/codecs/LengthDelimitedDecoder.java | 13 +++++-
 .../nio/codecs/TestLengthDelimitedDecoder.java  | 47 ++++++++++++++++++++
 .../http/impl/io/ContentLengthInputStream.java  | 29 +++++++++---
 .../impl/io/TestContentLengthInputStream.java   | 34 +++++++++++---
 5 files changed, 116 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef786ef0/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index e3a999e..7934625 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,4 +1,5 @@
 Release 4.1.1
+-------------------
 
 This is a patch release that fixes a number of non-critical issues found since release 4.1.
 
@@ -11,6 +12,12 @@ Please note that several classes and methods deprecated between versions 4.0-bet
 Users of 4.0.x versions are advised to upgrade and replace deprecated API calls following
 recommendations in javadocs.  
 
+* In case of an unexpected end of stream condition (the peer closed connection prematurely) 
+  truncated Content-Length delimited message bodies will cause an I/O exception. Application
+  can still choose to catch and ignore ConnectionClosedException in order to accept partial 
+  message content.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-255]: Fixed resource management in InputStreamEntity#writeTo()
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef786ef0/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
index 8097f95..1f12d8b 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
@@ -32,6 +32,7 @@ import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.ReadableByteChannel;
 
+import org.apache.http.ConnectionClosedException;
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.nio.FileContentDecoder;
 import org.apache.http.nio.reactor.SessionInputBuffer;
@@ -97,7 +98,11 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
         }
         if (bytesRead == -1) {
             this.completed = true;
-            return -1;
+            if (this.len < this.contentLength) {
+                throw new ConnectionClosedException(
+                        "Premature end of Content-Length delimited message body (expected: "
+                        + this.contentLength + "; received: " + this.len);
+            }
         }
         this.len += bytesRead;
         if (this.len >= this.contentLength) {
@@ -149,7 +154,11 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
         }
         if (bytesRead == -1) {
             this.completed = true;
-            return -1;
+            if (this.len < this.contentLength) {
+                throw new ConnectionClosedException(
+                        "Premature end of Content-Length delimited message body (expected: "
+                        + this.contentLength + "; received: " + this.len);
+            }
         }
         this.len += bytesRead;
         if (this.len >= this.contentLength) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef786ef0/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java b/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
index 2ab516e..1c005b2 100644
--- a/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
+++ b/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
@@ -38,6 +38,7 @@ import java.nio.channels.ReadableByteChannel;
 
 import junit.framework.TestCase;
 
+import org.apache.http.ConnectionClosedException;
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBufferImpl;
 import org.apache.http.mockup.ReadableByteChannelMockup;
@@ -516,4 +517,50 @@ public class TestLengthDelimitedDecoder extends TestCase {
         assertEquals(0, metrics.getBytesTransferred());
     }
 
+    public void testTruncatedContent() throws Exception {
+        ReadableByteChannel channel = new ReadableByteChannelMockup(
+                new String[] {"1234567890"}, "US-ASCII");
+        HttpParams params = new BasicHttpParams();
+
+        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 20);
+
+        ByteBuffer dst = ByteBuffer.allocate(1024);
+
+        int bytesRead = decoder.read(dst);
+        assertEquals(10, bytesRead);
+        try {
+            decoder.read(dst);
+            fail("ClosedChannelException should have been thrown");
+        } catch (ConnectionClosedException ex) {
+        }
+    }
+
+    public void testTruncatedContentWithFile() throws Exception {
+        ReadableByteChannel channel = new ReadableByteChannelMockup(
+                new String[] {"1234567890"}, "US-ASCII");
+        HttpParams params = new BasicHttpParams();
+
+        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 20);
+
+        File fileHandle = File.createTempFile("testFile", ".txt");
+        RandomAccessFile testfile  = new RandomAccessFile(fileHandle, "rw");
+        FileChannel fchannel = testfile.getChannel();
+        long bytesRead = decoder.transfer(fchannel, 0, Integer.MAX_VALUE);
+        assertEquals(10, bytesRead);
+        try {
+            decoder.transfer(fchannel, 10, Integer.MAX_VALUE);
+            fail("ClosedChannelException should have been thrown");
+        } catch (ConnectionClosedException ex) {
+        } finally {
+            testfile.close();
+            deleteWithCheck(fileHandle);
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef786ef0/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
index b53b9d5..e606b0e 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
@@ -30,6 +30,7 @@ package org.apache.http.impl.io;
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.apache.http.ConnectionClosedException;
 import org.apache.http.io.BufferInfo;
 import org.apache.http.io.SessionInputBuffer;
 
@@ -99,8 +100,10 @@ public class ContentLengthInputStream extends InputStream {
     public void close() throws IOException {
         if (!closed) {
             try {
-                byte buffer[] = new byte[BUFFER_SIZE];
-                while (read(buffer) >= 0) {
+                if (pos < contentLength) {
+                    byte buffer[] = new byte[BUFFER_SIZE];
+                    while (read(buffer) >= 0) {
+                    }
                 }
             } finally {
                 // close after above so that we don't throw an exception trying
@@ -133,8 +136,17 @@ public class ContentLengthInputStream extends InputStream {
         if (pos >= contentLength) {
             return -1;
         }
-        pos++;
-        return this.in.read();
+        int b = this.in.read();
+        if (b == -1) {
+            if (pos < contentLength) {
+                throw new ConnectionClosedException(
+                        "Premature end of Content-Length delimited message body (expected: "
+                        + contentLength + "; received: " + pos);
+            }
+        } else {
+            pos++;
+        }
+        return b;
     }
 
     /**
@@ -162,7 +174,14 @@ public class ContentLengthInputStream extends InputStream {
             len = (int) (contentLength - pos);
         }
         int count = this.in.read(b, off, len);
-        pos += count;
+        if (count == -1 && pos < contentLength) {
+            throw new ConnectionClosedException(
+                    "Premature end of Content-Length delimited message body (expected: "
+                    + contentLength + "; received: " + pos);
+        }
+        if (count > 0) {
+            pos += count;
+        }
         return count;
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef786ef0/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java b/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
index 83b73f2..ea6d5ac 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
@@ -33,7 +33,9 @@ import java.io.InputStream;
 
 import junit.framework.TestCase;
 
+import org.apache.http.ConnectionClosedException;
 import org.apache.http.mockup.SessionInputBufferMockup;
+import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.util.EncodingUtils;
 
 public class TestContentLengthInputStream extends TestCase {
@@ -93,10 +95,6 @@ public class TestContentLengthInputStream extends TestCase {
         assertTrue(in.skip(-1) == 0);
         assertTrue(in.read() == -1);
 
-        in = new ContentLengthInputStream(new SessionInputBufferMockup(new byte[2]), 4L);
-        in.read();
-        assertTrue(in.skip(2) == 1);
-
         in = new ContentLengthInputStream(new SessionInputBufferMockup(new byte[20]), 10L);
         assertEquals(5,in.skip(5));
         assertEquals(5, in.read(new byte[20]));
@@ -111,9 +109,10 @@ public class TestContentLengthInputStream extends TestCase {
     }
 
     public void testClose() throws IOException {
-        String correct = "1234567890123456";
-        InputStream in = new ContentLengthInputStream(new SessionInputBufferMockup(
-            EncodingUtils.getBytes(correct, CONTENT_CHARSET)), 10L);
+        String correct = "1234567890123456-";
+        SessionInputBuffer inbuffer = new SessionInputBufferMockup(
+                EncodingUtils.getBytes(correct, CONTENT_CHARSET));
+        InputStream in = new ContentLengthInputStream(inbuffer, 16L);
         in.close();
         in.close();
         try {
@@ -135,6 +134,27 @@ public class TestContentLengthInputStream extends TestCase {
         } catch (IOException ex) {
             // expected
         }
+        assertEquals('-', inbuffer.read());
+    }
+
+    public void testTruncatedContent() throws IOException {
+        String correct = "1234567890123456";
+        SessionInputBuffer inbuffer = new SessionInputBufferMockup(EncodingUtils.getBytes(
+                correct, CONTENT_CHARSET));
+        InputStream in = new ContentLengthInputStream(inbuffer, 32L);
+        byte[] tmp = new byte[32];
+        int byteRead = in.read(tmp);
+        assertEquals(16, byteRead);
+        try {
+            in.read(tmp);
+            fail("ConnectionClosedException should have been closed");
+        } catch (ConnectionClosedException ex) {
+        }
+        try {
+            in.read();
+            fail("ConnectionClosedException should have been closed");
+        } catch (ConnectionClosedException ex) {
+        }
     }
 
 }


[02/35] httpcomponents-core git commit: Updated 4.1.1 release notes

Posted by ol...@apache.org.
Updated 4.1.1 release notes

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1101172 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 77e0583115a85a4c6296475016bf404f9b83400d
Parents: 391cc9d
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Mon May 9 19:49:58 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Mon May 9 19:49:58 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/77e05831/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 6904f1b..e3a999e 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,4 +1,15 @@
-Changes since 4.1
+Release 4.1.1
+
+This is a patch release that fixes a number of non-critical issues found since release 4.1.
+
+This release marks the end of support for Java 1.3. As of release 4.2 HttpCore will require 
+Java 1.5 for all its components. 
+
+Please note that several classes and methods deprecated between versions 4.0-beta1 and 4.0 GA 
+(more than two years ago) will also be removed in the 4.2 branch.
+
+Users of 4.0.x versions are advised to upgrade and replace deprecated API calls following
+recommendations in javadocs.  
 
 * [HTTPCORE-255]: Fixed resource management in InputStreamEntity#writeTo()
   Contributed by Oleg Kalnichevski <olegk at apache.org>


[09/35] httpcomponents-core git commit: HTTPCORE-261: IOSession#setSocketTimeout() method does not reset the timeout count (merged from trunk)

Posted by ol...@apache.org.
HTTPCORE-261: IOSession#setSocketTimeout() method does not reset the timeout count (merged from trunk)

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1140270 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: a2c7e6216c84ea944acf847c9ba5533ace032837
Parents: 5fff28b
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Mon Jun 27 19:06:14 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Mon Jun 27 19:06:14 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  3 +
 .../impl/nio/reactor/AbstractIOReactor.java     | 57 ++++++++++++++-----
 .../http/impl/nio/reactor/BaseIOReactor.java    | 59 +++++---------------
 .../http/impl/nio/reactor/IOSessionImpl.java    | 42 +++++++++++++-
 .../http/impl/nio/reactor/SSLIOSession.java     |  5 +-
 .../http/impl/nio/reactor/SessionHandle.java    |  3 +
 .../http/nio/entity/SkipContentListener.java    |  3 -
 7 files changed, 107 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a2c7e621/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 2c731d7..9ac0b52 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,9 @@
 Changes since 4.1.1
 -------------------
 
+* [HTTPCORE-261] IOSession#setSocketTimeout() method does not reset the timeout count. 
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-260] Non-blocking SSL I/O session can terminate prematurely causing message body 
   truncation when message content is chunk coded and the connection is closed on the opposite end. 
   Contributed by Oleg Kalnichevski <olegk at apache.org>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a2c7e621/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
index b75c6b2..d6f21e0 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
@@ -144,17 +144,6 @@ public abstract class AbstractIOReactor implements IOReactor {
     protected abstract void writable(SelectionKey key);
 
     /**
-     * Triggered to verify whether the I/O session associated with the
-     * given selection key has not timed out.
-     * <p>
-     * Super-classes can implement this method to react to the event.
-     *
-     * @param key the selection key.
-     * @param now current time as long value.
-     */
-    protected abstract void timeoutCheck(SelectionKey key, long now);
-
-    /**
      * Triggered to validate keys currently registered with the selector. This
      * method is called after each I/O select loop.
      * <p>
@@ -174,7 +163,8 @@ public abstract class AbstractIOReactor implements IOReactor {
      * @param key the selection key.
      * @param session new I/O session.
      */
-    protected abstract void sessionCreated(SelectionKey key, IOSession session);
+    protected void sessionCreated(final SelectionKey key, final IOSession session) {
+    }
 
     /**
      * Triggered when a session has been closed.
@@ -183,7 +173,18 @@ public abstract class AbstractIOReactor implements IOReactor {
      *
      * @param session closed I/O session.
      */
-    protected abstract void sessionClosed(IOSession session);
+    protected void sessionClosed(final IOSession session) {
+    }
+
+    /**
+     * Triggered when a session has timed out.
+     * <p>
+     * Super-classes can implement this method to react to the event.
+     *
+     * @param session timed out I/O session.
+     */
+    protected void sessionTimedOut(final IOSession session) {
+    }
 
     /**
      * Obtains {@link IOSession} instance associated with the given selection
@@ -192,7 +193,9 @@ public abstract class AbstractIOReactor implements IOReactor {
      * @param key the selection key.
      * @return I/O session.
      */
-    protected abstract IOSession getSession(SelectionKey key);
+    protected IOSession getSession(final SelectionKey key) {
+        return (IOSession) key.attachment();
+    }
 
     public IOReactorStatus getStatus() {
         return this.status;
@@ -324,6 +327,7 @@ public abstract class AbstractIOReactor implements IOReactor {
      * @param key the selection key that triggered an event.
      */
     protected void processEvent(final SelectionKey key) {
+        IOSessionImpl session = (IOSessionImpl) key.attachment();
         try {
             if (key.isAcceptable()) {
                 acceptable(key);
@@ -332,13 +336,14 @@ public abstract class AbstractIOReactor implements IOReactor {
                 connectable(key);
             }
             if (key.isReadable()) {
+                session.resetLastRead();
                 readable(key);
             }
             if (key.isWritable()) {
+                session.resetLastWrite();
                 writable(key);
             }
         } catch (CancelledKeyException ex) {
-            IOSession session = getSession(key);
             queueClosedSession(session);
             key.attach(null);
         }
@@ -416,6 +421,7 @@ public abstract class AbstractIOReactor implements IOReactor {
                 if (sessionRequest != null) {
                     sessionRequest.completed(session);
                 }
+                key.attach(session);
                 sessionCreated(key, session);
             } catch (CancelledKeyException ex) {
                 queueClosedSession(session);
@@ -469,6 +475,27 @@ public abstract class AbstractIOReactor implements IOReactor {
     }
 
     /**
+     * Triggered to verify whether the I/O session associated with the
+     * given selection key has not timed out.
+     * <p>
+     * Super-classes can implement this method to react to the event.
+     *
+     * @param key the selection key.
+     * @param now current time as long value.
+     */
+    protected void timeoutCheck(final SelectionKey key, long now) {
+        IOSessionImpl session = (IOSessionImpl) key.attachment();
+        if (session != null) {
+            int timeout = session.getSocketTimeout();
+            if (timeout > 0) {
+                if (session.getLastAccessTime() + timeout < now) {
+                    sessionTimedOut(session);
+                }
+            }
+        }
+    }
+
+    /**
      * Closes out all I/O sessions maintained by this I/O reactor.
      */
     protected void closeSessions() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a2c7e621/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
index 6e943e1..7676c00 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
@@ -109,7 +109,7 @@ public class BaseIOReactor extends AbstractIOReactor {
      *
      * @param exceptionHandler the exception handler.
      */
-    public void setExceptionHandler(IOReactorExceptionHandler exceptionHandler) {
+    public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
         this.exceptionHandler = exceptionHandler;
     }
 
@@ -153,10 +153,7 @@ public class BaseIOReactor extends AbstractIOReactor {
      */
     @Override
     protected void readable(final SelectionKey key) {
-        SessionHandle handle = (SessionHandle) key.attachment();
-        IOSession session = handle.getSession();
-        handle.resetLastRead();
-
+        IOSession session = getSession(key);
         try {
             this.eventDispatch.inputReady(session);
             if (session.hasBufferedInput()) {
@@ -177,10 +174,7 @@ public class BaseIOReactor extends AbstractIOReactor {
      */
     @Override
     protected void writable(final SelectionKey key) {
-        SessionHandle handle = (SessionHandle) key.attachment();
-        IOSession session = handle.getSession();
-        handle.resetLastWrite();
-
+        IOSession session = getSession(key);
         try {
             this.eventDispatch.outputReady(session);
         } catch (CancelledKeyException ex) {
@@ -247,57 +241,32 @@ public class BaseIOReactor extends AbstractIOReactor {
     }
 
     /**
-     * Performs timeout check for the I/O session associated with the given
-     * selection key.
-     */
-    @Override
-    protected void timeoutCheck(final SelectionKey key, long now) {
-        Object attachment = key.attachment();
-        if (attachment instanceof SessionHandle) {
-            SessionHandle handle = (SessionHandle) key.attachment();
-            IOSession session = handle.getSession();
-            int timeout = session.getSocketTimeout();
-            if (timeout > 0) {
-                if (handle.getLastAccessTime() + timeout < now) {
-                    try {
-                        this.eventDispatch.timeout(session);
-                    } catch (CancelledKeyException ex) {
-                        queueClosedSession(session);
-                        key.attach(null);
-                    } catch (RuntimeException ex) {
-                        handleRuntimeException(ex);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
      * Processes newly created I/O session. This method dispatches the event
      * notification to the {@link IOEventDispatch#connected(IOSession)} method.
      */
     @Override
     protected void sessionCreated(final SelectionKey key, final IOSession session) {
-        SessionHandle handle = new SessionHandle(session);
-        key.attach(handle);
         try {
             this.eventDispatch.connected(session);
         } catch (CancelledKeyException ex) {
             queueClosedSession(session);
-            key.attach(null);
         } catch (RuntimeException ex) {
             handleRuntimeException(ex);
         }
     }
 
+    /**
+     * Processes timed out I/O session. This method dispatches the event
+     * notification to the {@link IOEventDispatch#timeout(IOSession)} method.
+     */
     @Override
-    protected IOSession getSession(final SelectionKey key) {
-        Object attachment = key.attachment();
-        if (attachment instanceof SessionHandle) {
-            SessionHandle handle = (SessionHandle) attachment;
-            return handle.getSession();
-        } else {
-            return null;
+    protected void sessionTimedOut(final IOSession session) {
+        try {
+            this.eventDispatch.timeout(session);
+        } catch (CancelledKeyException ex) {
+            queueClosedSession(session);
+        } catch (RuntimeException ex) {
+            handleRuntimeException(ex);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a2c7e621/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index 97f0821..31e6682 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -58,6 +58,12 @@ public class IOSessionImpl implements IOSession {
     private volatile SessionBufferStatus bufferStatus;
     private volatile int socketTimeout;
 
+    private final long startedTime;
+
+    private long lastReadTime;
+    private long lastWriteTime;
+    private long lastAccessTime;
+
     /**
      * Creates new instance of IOSessionImpl.
      *
@@ -83,6 +89,11 @@ public class IOSessionImpl implements IOSession {
         this.currentEventMask = 0;
         this.socketTimeout = 0;
         this.status = ACTIVE;
+        long now = System.currentTimeMillis();
+        this.startedTime = now;
+        this.lastReadTime = now;
+        this.lastWriteTime = now;
+        this.lastAccessTime = now;
     }
 
     /**
@@ -186,8 +197,9 @@ public class IOSessionImpl implements IOSession {
         return this.socketTimeout;
     }
 
-    public void setSocketTimeout(int timeout) {
+    public synchronized void setSocketTimeout(int timeout) {
         this.socketTimeout = timeout;
+        this.lastAccessTime = System.currentTimeMillis();
     }
 
     public synchronized void close() {
@@ -250,6 +262,34 @@ public class IOSessionImpl implements IOSession {
         this.attributes.put(name, obj);
     }
 
+    synchronized long getStartedTime() {
+        return this.startedTime;
+    }
+
+    synchronized long getLastReadTime() {
+        return this.lastReadTime;
+    }
+
+    synchronized long getLastWriteTime() {
+        return this.lastWriteTime;
+    }
+
+    synchronized long getLastAccessTime() {
+        return this.lastAccessTime;
+    }
+
+    synchronized void resetLastRead() {
+        long now = System.currentTimeMillis();
+        this.lastReadTime = now;
+        this.lastAccessTime = now;
+    }
+
+    synchronized void resetLastWrite() {
+        long now = System.currentTimeMillis();
+        this.lastWriteTime = now;
+        this.lastAccessTime = now;
+    }
+
     private static void formatOps(final StringBuffer buffer, int ops) {
         if ((ops & SelectionKey.OP_READ) > 0) {
             buffer.append('r');

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a2c7e621/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
index 5e67cc2..8c0a488 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
@@ -235,6 +235,9 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
     }
 
     private int receiveEncryptedData() throws IOException {
+        if (this.endOfStream) {
+            return -1;
+        }
         return this.session.channel().read(this.inEncrypted);
     }
 
@@ -456,7 +459,7 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
         buffer.append("][");
         buffer.append(this.sslEngine.getHandshakeStatus());
         if (this.endOfStream) {
-            buffer.append("EOF][");
+            buffer.append("][EOF][");
         }
         buffer.append("][");
         buffer.append(this.inEncrypted.position());

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a2c7e621/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java
index a9c7b30..09c308b 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java
@@ -34,8 +34,11 @@ import org.apache.http.nio.reactor.IOSession;
  * to a {@link IOSession} along with information about time of last I/O
  * operations on that session.
  *
+ * @deprecated use {@link IOSessionImpl}
+ *
  * @since 4.0
  */
+@Deprecated
 public class SessionHandle {
 
     private final IOSession session;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a2c7e621/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
index 06f654a..35b869b 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
@@ -54,13 +54,10 @@ public class SkipContentListener implements ContentListener {
     public void contentAvailable(
             final ContentDecoder decoder,
             final IOControl ioctrl) throws IOException {
-        int totalRead = 0;
         int lastRead;
         do {
             buffer.clear();
             lastRead = decoder.read(buffer);
-            if (lastRead > 0)
-                totalRead += lastRead;
         } while (lastRead > 0);
     }
 


[15/35] httpcomponents-core git commit: Updated release notes for HttpCore 4.1.2 release

Posted by ol...@apache.org.
Updated release notes for HttpCore 4.1.2 release

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1144813 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 31b7131604c14936b0b605b199c36e490bfaccac
Parents: 34efab7
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Jul 10 10:47:25 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Jul 10 10:47:25 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/31b71316/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 9ac0b52..1f47c4b 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,14 @@
-Changes since 4.1.1
+Release 4.1.2
 -------------------
 
+This is a patch release that fixes a number of bugs found in the previous version.
+
+Please note that several classes and methods deprecated between versions 4.0-beta1 and 4.0 GA 
+(more than two years ago) will also be removed in the 4.2 branch.
+
+Users of 4.0.x versions are advised to upgrade and replace deprecated API calls following
+recommendations in javadocs.  
+
 * [HTTPCORE-261] IOSession#setSocketTimeout() method does not reset the timeout count. 
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 


[30/35] httpcomponents-core git commit: Updated release notes and project web site for HttpCore 4.1.4 release

Posted by ol...@apache.org.
Updated release notes and project web site for HttpCore 4.1.4 release

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1220436 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: f2c14f9983cc3f8ce3e75f4d0fefcb5f5b5f7ceb
Parents: f99c949
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Dec 18 15:40:04 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Dec 18 15:40:04 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt         | 5 ++++-
 src/site/apt/download.apt | 8 ++++----
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f2c14f99/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index a1245c7..b45a5bb 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,9 @@
-Changes since 4.1.3
+Release 4.1.4
 -------------------
 
+This is a maintenance release that fixes a number of bugs found since release 4.1.4. It is also 
+likely to be the last release in the 4.1.x branch.
+
 * [HTTPCORE-286] Canceled I/O session can cause an IllegalStateException in BaseIOReactor#validate
   leading to an abnormal termination of the I/O reactor.
   Contributed by Oleg Kalnichevski <olegk at apache.org>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f2c14f99/src/site/apt/download.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/download.apt b/src/site/apt/download.apt
index c4c6f72..d3e201f 100644
--- a/src/site/apt/download.apt
+++ b/src/site/apt/download.apt
@@ -42,24 +42,24 @@ HttpCore Downloads
     in your {{{http://maven.apache.org/guides/introduction/introduction-to-the-pom.html}pom.xml}} 
     by adding the following block to the dependency descriptor:
 
-* {HttpComponents Core 4.1.3}
+* {HttpComponents Core 4.1.4}
 
 -------------------------
   <dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcore</artifactId>
-    <version>4.1.3</version>
+    <version>4.1.4</version>
     <scope>compile</scope>
   </dependency>
 -------------------------
 
-* {HttpComponents Core NIO 4.1.3}
+* {HttpComponents Core NIO 4.1.4}
 
 -------------------------
   <dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcore-nio</artifactId>
-    <version>4.1.3</version>
+    <version>4.1.4</version>
     <scope>compile</scope>
   </dependency>
 -------------------------


[32/35] httpcomponents-core git commit: Updated NOTICE.txt and release notes

Posted by ol...@apache.org.
Updated NOTICE.txt and release notes

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1220905 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: c1a16885dd46cacb38b82260889366ec7facf1f1
Parents: 5d4113f
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Mon Dec 19 19:20:47 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Mon Dec 19 19:20:47 2011 +0000

----------------------------------------------------------------------
 NOTICE.txt        | 2 +-
 RELEASE_NOTES.txt | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c1a16885/NOTICE.txt
----------------------------------------------------------------------
diff --git a/NOTICE.txt b/NOTICE.txt
index a4e7ed3..bb263ab 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,5 @@
 Apache HttpComponents Core
-Copyright 2005-2010 The Apache Software Foundation
+Copyright 2005-2011 The Apache Software Foundation
 
 This product includes software developed by
 The Apache Software Foundation (http://www.apache.org/).

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c1a16885/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 17ad9f0..baf4dfb 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,8 +1,8 @@
 Release 4.1.4
 -------------------
 
-This is a maintenance release that fixes a number of bugs found since release 4.1.3. It is also 
-likely to be the last release in the 4.1.x branch.
+This is a maintenance release that fixes a number of bugs found since 4.1.3. It is also likely 
+to be the last release in the 4.1.x branch.
 
 * [HTTPCORE-286] Canceled I/O session can cause an IllegalStateException in BaseIOReactor#validate
   leading to an abnormal termination of the I/O reactor.


[07/35] httpcomponents-core git commit: HTTPCORE-260: Non-blocking SSL I/O session can terminate prematurely causing message body truncation when message content is chunk coded and the connection is closed on the opposite end

Posted by ol...@apache.org.
HTTPCORE-260: Non-blocking SSL I/O session can terminate prematurely causing message body truncation when message content is chunk coded and the connection is closed on the opposite end


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1134570 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: ee0f37775b84b93ad8d1191f30c7299376891d70
Parents: 7b3c167
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat Jun 11 11:15:25 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Jun 11 11:15:25 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               | 11 +++++
 .../http/impl/nio/reactor/IOSessionImpl.java    | 19 ++++---
 .../http/impl/nio/reactor/SSLIOSession.java     | 52 ++++++++++----------
 3 files changed, 51 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ee0f3777/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 7934625..2c731d7 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,3 +1,14 @@
+Changes since 4.1.1
+-------------------
+
+* [HTTPCORE-260] Non-blocking SSL I/O session can terminate prematurely causing message body 
+  truncation when message content is chunk coded and the connection is closed on the opposite end. 
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+* [HTTPCORE-257] Fixed incorrect results produced by DefaultConnectionReuseStrategy when handling 
+  response messages whose content entity has been decoded or modified by a protocol interceptor. 
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 Release 4.1.1
 -------------------
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ee0f3777/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index 80a986a..97f0821 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -251,7 +251,6 @@ public class IOSessionImpl implements IOSession {
     }
 
     private static void formatOps(final StringBuffer buffer, int ops) {
-        buffer.append('[');
         if ((ops & SelectionKey.OP_READ) > 0) {
             buffer.append('r');
         }
@@ -264,21 +263,29 @@ public class IOSessionImpl implements IOSession {
         if ((ops & SelectionKey.OP_CONNECT) > 0) {
             buffer.append('c');
         }
-        buffer.append(']');
     }
 
     @Override
     public synchronized String toString() {
         StringBuffer buffer = new StringBuffer();
         buffer.append("[");
+        switch (this.status) {
+        case ACTIVE:
+            buffer.append("ACTIVE");
+            break;
+        case CLOSING:
+            buffer.append("CLOSING");
+            break;
+        case CLOSED:
+            buffer.append("CLOSED");
+            break;
+        }
+        buffer.append("][");
         if (this.key.isValid()) {
-            buffer.append("interest ops: ");
             formatOps(buffer, this.interestOpsCallback != null ?
                     this.currentEventMask : this.key.interestOps());
-            buffer.append("; ready ops: ");
+            buffer.append(":");
             formatOps(buffer, this.key.readyOps());
-        } else {
-            buffer.append("invalid");
         }
         buffer.append("]");
         return buffer.toString();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ee0f3777/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
index bfed421..5e67cc2 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
@@ -156,9 +156,6 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
                 if (result.getStatus() != Status.OK) {
                     handshaking = false;
                 }
-                if (result.getStatus() == Status.CLOSED) {
-                    this.status = CLOSED;
-                }
                 break;
             case NEED_UNWRAP:
                 // Process incoming handshake data
@@ -168,12 +165,6 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
                 if (result.getStatus() != Status.OK) {
                     handshaking = false;
                 }
-                if (result.getStatus() == Status.CLOSED) {
-                    this.status = CLOSED;
-                }
-                if (result.getStatus() == Status.BUFFER_UNDERFLOW && this.endOfStream) {
-                    this.status = CLOSED;
-                }
                 break;
             case NEED_TASK:
                 Runnable r = this.sslEngine.getDelegatedTask();
@@ -198,7 +189,8 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
     }
 
     private void updateEventMask() {
-        if (this.sslEngine.isInboundDone() && this.sslEngine.isOutboundDone()) {
+        if (this.status == CLOSING &&
+                this.sslEngine.isInboundDone() && this.sslEngine.isOutboundDone()) {
             this.status = CLOSED;
         }
         if (this.status == CLOSED) {
@@ -255,12 +247,6 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
             this.inEncrypted.compact();
 
             opStatus = result.getStatus();
-            if (opStatus == Status.CLOSED) {
-                this.status = CLOSED;
-            }
-            if (opStatus == Status.BUFFER_UNDERFLOW && this.endOfStream) {
-                this.status = CLOSED;
-            }
             if (opStatus == Status.OK) {
                 decrypted = true;
             }
@@ -351,18 +337,19 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
         }
     }
 
-    public void close() {
-        if (this.status != ACTIVE) {
+    public synchronized void close() {
+        if (this.status >= CLOSING) {
             return;
         }
         this.status = CLOSING;
-        synchronized(this) {
-            this.sslEngine.closeOutbound();
-            updateEventMask();
-        }
+        this.sslEngine.closeOutbound();
+        updateEventMask();
     }
 
-    public void shutdown() {
+    public synchronized void shutdown() {
+        if (this.status == CLOSED) {
+            return;
+        }
         this.status = CLOSED;
         this.session.shutdown();
     }
@@ -372,7 +359,7 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
     }
 
     public boolean isClosed() {
-        return this.status != ACTIVE;
+        return this.status >= CLOSING;
     }
 
     public synchronized boolean isInboundDone() {
@@ -454,8 +441,23 @@ public class SSLIOSession implements IOSession, SessionBufferStatus {
     public String toString() {
         StringBuffer buffer = new StringBuffer();
         buffer.append(this.session);
-        buffer.append("[SSL handshake status: ");
+        buffer.append("[");
+        switch (this.status) {
+        case ACTIVE:
+            buffer.append("ACTIVE");
+            break;
+        case CLOSING:
+            buffer.append("CLOSING");
+            break;
+        case CLOSED:
+            buffer.append("CLOSED");
+            break;
+        }
+        buffer.append("][");
         buffer.append(this.sslEngine.getHandshakeStatus());
+        if (this.endOfStream) {
+            buffer.append("EOF][");
+        }
         buffer.append("][");
         buffer.append(this.inEncrypted.position());
         buffer.append("][");


[10/35] httpcomponents-core git commit: HTTPCLIENT-1072: inline nested jars in OSGi bundles

Posted by ol...@apache.org.
HTTPCLIENT-1072: inline nested jars in OSGi bundles

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1140280 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 886e6aaa45a48785a429972353fa78c5827ffafe
Parents: a2c7e62
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Mon Jun 27 19:17:50 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Mon Jun 27 19:17:50 2011 +0000

----------------------------------------------------------------------
 httpcore-osgi/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/886e6aaa/httpcore-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-osgi/pom.xml b/httpcore-osgi/pom.xml
index 644925a..e2de942 100644
--- a/httpcore-osgi/pom.xml
+++ b/httpcore-osgi/pom.xml
@@ -73,7 +73,7 @@
             <Bundle-SymbolicName>${project.groupId}.httpcore</Bundle-SymbolicName>
             <Import-Package>!org.apache.http*,*</Import-Package>            
             <_exportcontents>org.apache.http.*;version=${project.version}</_exportcontents>
-            <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
+            <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
             <!-- Stop the JAVA_1_n_HOME variables from being treated as headers by Bnd -->
             <_removeheaders>JAVA_1_3_HOME,JAVA_1_4_HOME</_removeheaders>
           </instructions>


[12/35] httpcomponents-core git commit: avoid NPE when address is unresolved and connection debugging is used

Posted by ol...@apache.org.
avoid NPE when address is unresolved and connection debugging is used


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1143789 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 42868c56b0c9ea548aea6262fea2b862babc107f
Parents: 8eef5fb
Author: Asankha Chamath Perera <as...@apache.org>
Authored: Thu Jul 7 12:18:55 2011 +0000
Committer: Asankha Chamath Perera <as...@apache.org>
Committed: Thu Jul 7 12:18:55 2011 +0000

----------------------------------------------------------------------
 .../org/apache/http/impl/nio/DefaultNHttpClientConnection.java   | 4 ++--
 .../org/apache/http/impl/nio/DefaultNHttpServerConnection.java   | 4 ++--
 .../java/org/apache/http/impl/nio/reactor/IOSessionImpl.java     | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/42868c56/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
index c7abf7a..bcca530 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
@@ -264,11 +264,11 @@ public class DefaultNHttpClientConnection
             final InetSocketAddress remote = ((InetSocketAddress) this.session.getRemoteAddress());
             final InetSocketAddress local  = ((InetSocketAddress) this.session.getLocalAddress());
 
-            buf.append(local.getAddress().getHostAddress())
+            buf.append(local.getAddress() != null ? local.getAddress().getHostAddress() : local.getAddress())
             .append(':')
             .append(local.getPort())
             .append("->")
-            .append(remote.getAddress().getHostAddress())
+            .append(remote.getAddress() != null ? remote.getAddress().getHostAddress() : remote.getAddress())
             .append(':')
             .append(remote.getPort());
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/42868c56/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index 59592de..c78ae24 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -266,11 +266,11 @@ public class DefaultNHttpServerConnection
             final InetSocketAddress remote = ((InetSocketAddress) this.session.getRemoteAddress());
             final InetSocketAddress local  = ((InetSocketAddress) this.session.getLocalAddress());
 
-            buf.append(remote.getAddress().getHostAddress())
+            buf.append(remote.getAddress() != null ? remote.getAddress().getHostAddress() : remote.getAddress())
             .append(':')
             .append(remote.getPort())
             .append("->")
-            .append(local.getAddress().getHostAddress())
+            .append(local.getAddress() != null ? local.getAddress().getHostAddress() : local.getAddress())
             .append(':')
             .append(local.getPort());
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/42868c56/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index dbc4d99..30b3e70 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -316,11 +316,11 @@ public class IOSessionImpl implements IOSession {
             final InetSocketAddress remote = ((InetSocketAddress) getRemoteAddress());
             final InetSocketAddress local  = ((InetSocketAddress) getLocalAddress());
 
-            buffer.append(local.getAddress().getHostAddress())
+            buffer.append(local.getAddress() != null ? local.getAddress().getHostAddress() : local.getAddress())
             .append(':')
             .append(local.getPort())
             .append("<->")
-            .append(remote.getAddress().getHostAddress())
+            .append(remote.getAddress() != null ? remote.getAddress().getHostAddress() : remote.getAddress())
             .append(':')
             .append(remote.getPort());
 


[27/35] httpcomponents-core git commit: Added missing parameters to javadoc

Posted by ol...@apache.org.
Added missing parameters to javadoc

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1210152 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: ab58c97497e992698209634510c29dcca239fe9d
Parents: d53511f
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Dec 4 17:33:05 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Dec 4 17:33:05 2011 +0000

----------------------------------------------------------------------
 .../java/org/apache/http/impl/AbstractHttpClientConnection.java    | 1 +
 .../java/org/apache/http/impl/AbstractHttpServerConnection.java    | 1 +
 .../java/org/apache/http/impl/DefaultHttpClientConnection.java     | 2 ++
 .../java/org/apache/http/impl/DefaultHttpServerConnection.java     | 2 ++
 .../main/java/org/apache/http/impl/SocketHttpClientConnection.java | 1 +
 .../main/java/org/apache/http/impl/SocketHttpServerConnection.java | 1 +
 .../src/main/java/org/apache/http/impl/io/SocketInputBuffer.java   | 1 +
 .../src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java  | 1 +
 8 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ab58c974/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java b/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
index 0920643..b66ebc8 100644
--- a/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
@@ -64,6 +64,7 @@ import org.apache.http.params.HttpParams;
  * <ul>
  *  <li>{@link org.apache.http.params.CoreProtocolPNames#STRICT_TRANSFER_ENCODING}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
  * </ul>
  *
  * @since 4.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ab58c974/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java b/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
index 3a3e577..eb7de0e 100644
--- a/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
@@ -64,6 +64,7 @@ import org.apache.http.params.HttpParams;
  * <ul>
  *  <li>{@link org.apache.http.params.CoreProtocolPNames#STRICT_TRANSFER_ENCODING}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
  * </ul>
  *
  * @since 4.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ab58c974/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java b/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
index 437bcfb..10231fd 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
@@ -45,6 +45,8 @@ import org.apache.http.params.HttpParams;
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#SO_LINGER}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MIN_CHUNK_LIMIT}</li>
  * </ul>
  *
  * @since 4.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ab58c974/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java b/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
index fca1d94..3bea47c 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
@@ -45,6 +45,8 @@ import org.apache.http.params.HttpParams;
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#SO_LINGER}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MIN_CHUNK_LIMIT}</li>
  * </ul>
  *
  * @since 4.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ab58c974/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java b/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
index bf236cc..074a043 100644
--- a/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
@@ -53,6 +53,7 @@ import org.apache.http.params.HttpParams;
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MIN_CHUNK_LIMIT}</li>
  * </ul>
  *
  * @since 4.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ab58c974/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java b/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
index d146948..de0d440 100644
--- a/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
@@ -52,6 +52,7 @@ import org.apache.http.params.HttpParams;
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MIN_CHUNK_LIMIT}</li>
  * </ul>
  *
  * @since 4.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ab58c974/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java b/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java
index a0ff452..4ebc00c 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java
@@ -43,6 +43,7 @@ import org.apache.http.params.HttpParams;
  * <ul>
  *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MIN_CHUNK_LIMIT}</li>
  * </ul>
  *
  * @since 4.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ab58c974/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java b/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java
index f6654de..4e2f252 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java
@@ -40,6 +40,7 @@ import org.apache.http.params.HttpParams;
  * class:
  * <ul>
  *  <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#MIN_CHUNK_LIMIT}</li>
  * </ul>
  *
  * @since 4.0


[17/35] httpcomponents-core git commit: Upgraded project version to 4.1.3-SNAPSHOT

Posted by ol...@apache.org.
Upgraded project version to 4.1.3-SNAPSHOT

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1146861 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: 82b7e3d373c8a3903d66e0206ca936891aa9b95d
Parents: 8a033e7
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Thu Jul 14 19:21:20 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Thu Jul 14 19:21:20 2011 +0000

----------------------------------------------------------------------
 httpcore-ab/pom.xml        | 2 +-
 httpcore-benchmark/pom.xml | 2 +-
 httpcore-contrib/pom.xml   | 2 +-
 httpcore-nio/pom.xml       | 2 +-
 httpcore-osgi/pom.xml      | 2 +-
 httpcore/pom.xml           | 2 +-
 pom.xml                    | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/82b7e3d3/httpcore-ab/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-ab/pom.xml b/httpcore-ab/pom.xml
index 75e059a..912b860 100644
--- a/httpcore-ab/pom.xml
+++ b/httpcore-ab/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.2-SNAPSHOT</version>
+    <version>4.1.3-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-ab</artifactId>
   <name>HttpCore AB clone</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/82b7e3d3/httpcore-benchmark/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-benchmark/pom.xml b/httpcore-benchmark/pom.xml
index 29abae7..9768f0f 100644
--- a/httpcore-benchmark/pom.xml
+++ b/httpcore-benchmark/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.2-SNAPSHOT</version>
+    <version>4.1.3-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-benchmark</artifactId>
   <name>HttpCore Benchmarks</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/82b7e3d3/httpcore-contrib/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-contrib/pom.xml b/httpcore-contrib/pom.xml
index 9c55258..084b71b 100644
--- a/httpcore-contrib/pom.xml
+++ b/httpcore-contrib/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.2-SNAPSHOT</version>
+    <version>4.1.3-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-contrib</artifactId>
   <name>HttpCore Contrib</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/82b7e3d3/httpcore-nio/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-nio/pom.xml b/httpcore-nio/pom.xml
index 9208265..43d6885 100644
--- a/httpcore-nio/pom.xml
+++ b/httpcore-nio/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.2-SNAPSHOT</version>
+    <version>4.1.3-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-nio</artifactId>
   <name>HttpCore NIO</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/82b7e3d3/httpcore-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore-osgi/pom.xml b/httpcore-osgi/pom.xml
index e2de942..4d5c435 100644
--- a/httpcore-osgi/pom.xml
+++ b/httpcore-osgi/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.2-SNAPSHOT</version>
+    <version>4.1.3-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore-osgi</artifactId>
   <name>HttpCore OSGi bundle</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/82b7e3d3/httpcore/pom.xml
----------------------------------------------------------------------
diff --git a/httpcore/pom.xml b/httpcore/pom.xml
index 1b26447..c0e33c5 100644
--- a/httpcore/pom.xml
+++ b/httpcore/pom.xml
@@ -30,7 +30,7 @@
   <parent>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpcomponents-core</artifactId>
-    <version>4.1.2-SNAPSHOT</version>
+    <version>4.1.3-SNAPSHOT</version>
   </parent>
   <artifactId>httpcore</artifactId>
   <name>HttpCore</name>

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/82b7e3d3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b0e0bb5..c218ad9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,7 @@
   <groupId>org.apache.httpcomponents</groupId>
   <artifactId>httpcomponents-core</artifactId>
   <name>HttpComponents Core</name>
-  <version>4.1.2-SNAPSHOT</version>
+  <version>4.1.3-SNAPSHOT</version>
   <description>Core components to build HTTP enabled services</description>
   <url>http://hc.apache.org/httpcomponents-core</url>
   <inceptionYear>2005</inceptionYear>


[29/35] httpcomponents-core git commit: HTTPCORE-286: Canceled I/O session can cause an IllegalStateException in BaseIOReactor#validate leading to an abnormal termination of the I/O reactor

Posted by ol...@apache.org.
HTTPCORE-286: Canceled I/O session can cause an IllegalStateException in BaseIOReactor#validate leading to an abnormal termination of the I/O reactor

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1220405 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/4.1.x
Commit: f99c9493db5864586c3536d6ec3fc1cef2f6abbe
Parents: a92bd33
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Dec 18 13:48:12 2011 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Dec 18 13:48:12 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  6 ++++-
 .../http/impl/nio/reactor/BaseIOReactor.java    | 26 ++++++--------------
 2 files changed, 13 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f99c9493/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 8a3e3b9..a1245c7 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,13 +1,17 @@
 Changes since 4.1.3
 -------------------
 
+* [HTTPCORE-286] Canceled I/O session can cause an IllegalStateException in BaseIOReactor#validate
+  leading to an abnormal termination of the I/O reactor.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-257] Fixed incorrect results produced by DefaultConnectionReuseStrategy when handling 
   response messages whose content entity has been decoded or modified by a protocol interceptor. 
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 
 * [HTTPCORE-283] Workaround for a bug causing termination of the I/O reactor in case of exception 
   thrown by NHttpServiceHandler#requestReceived or NHttpClientHandler#responseReceived
-  methods. A more comprehensive fix for the bug applied to the (4.2 branch).
+  methods. A more comprehensive fix for the bug applied to the 4.2 branch.
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 
 * [HTTPCORE-281] ResponseConnControl protocol interceptor does not correctly populate connection

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f99c9493/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
index 7676c00..54e4d7f 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
@@ -213,28 +213,18 @@ public class BaseIOReactor extends AbstractIOReactor {
                     it.remove();
                     continue;
                 }
-
-                int ops = 0;
                 try {
-                    ops = session.getEventMask();
+                    if ((session.getEventMask() & EventMask.READ) > 0) {
+                        this.eventDispatch.inputReady(session);
+                        if (!session.hasBufferedInput()) {
+                            it.remove();
+                        }
+                    }
                 } catch (CancelledKeyException ex) {
                     it.remove();
                     queueClosedSession(session);
-                    continue;
-                }
-
-                if ((ops & EventMask.READ) > 0) {
-                    try {
-                        this.eventDispatch.inputReady(session);
-                    } catch (CancelledKeyException ex) {
-                        it.remove();
-                        queueClosedSession(session);
-                    } catch (RuntimeException ex) {
-                        handleRuntimeException(ex);
-                    }
-                    if (!session.hasBufferedInput()) {
-                        it.remove();
-                    }
+                } catch (RuntimeException ex) {
+                    handleRuntimeException(ex);
                 }
             }
         }