Am 2020-05-28 um 22:51 schrieb Oleg Kalnichevski:
On Thu, 2020-05-28 at 22:01 +0200, Michael Osipov wrote:
Am 2020-05-28 um 10:40 schrieb Oleg Kalnichevski:
On Thu, 2020-05-28 at 00:02 +0200, Michael Osipov wrote:



...

Please try out this patch. This should now give us proper out
of
sequence response check with minimal overhead. The check will
now
be
performed for chunks of 2048 bytes instead of each and every
write
operations.




https://github.com/ok2c/httpcomponents-core/commit/7baa51f873da759d4e81973d4ca0a16f4199c51b

This one does not work at all. It does even break the final
(authenticated) request. See for yourself:
http://home.apache.org/~michaelo/issues/early-response/try-3/


Please confirm this one works, at least for plain http:


https://github.com/ok2c/httpcomponents-core/commit/fb115a562921d8249a6bd8f3a5f5c4d6dba76949

Good news, this looks very decent for HTTP. HTTPS always fails.
I am quite amazed that the SSL socket stream (AppInputStream) has
such a
different behavior. Other buffers internally which make #available()
fail? There is an internal byte buffer of 4 KiB.

Output: http://home.apache.org/~michaelo/issues/early-response/try-4/



Great. Please pull one more commit from the same branch. It _should_
fix the out of sequence response check with SSL connections.

Eureka, it works!

Can you explain why SSLSocket requires different handling? Moreover, why not use "isDataAvailable(Timeout.ONE_MILLISECOND)" all the time? Avoiding filling the buffer?

If the different handling is necessary, here is a small proposal:
diff --git 
a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
 
b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
index 37d750fc2..050da1864 100644
--- 
a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
+++ 
b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
@@ -165,8 +165,4 @@ void checkForEarlyResponse() throws IOException {
-                        if (ssl) {
-                            if (isDataAvailable(Timeout.ONE_MILLISECOND)) {
-                                throw new ResponseOutOfOrderException();
-                            }
-                        } else {
-                            if (socketInputStream.available() > 0) {
-                                throw new ResponseOutOfOrderException();
-                            }
+                        final boolean dataAvailable = ssl ? 
isDataAvailable(Timeout.ONE_MILLISECOND) :
+                                (socketInputStream.available() > 0);
+                        if (dataAvailable) {
+                            throw new ResponseOutOfOrderException();


Here is the output: http://home.apache.org/~michaelo/issues/early-response/try-5/

Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to