hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [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
Date Tue, 09 May 2017 20:03:36 GMT
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 <olegk@apache.org>
Authored: Sat Jun 11 11:15:25 2011 +0000
Committer: Oleg Kalnichevski <olegk@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("][");


Mime
View raw message