Re-enable SSL handshake cutthrough support (and fixed unittest)
diff --git a/libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp b/libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp
index b474905..6489370 100644
--- a/libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp
+++ b/libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp
@@ -1022,6 +1022,10 @@
* and undesirable.)
*/
mode |= SSL_MODE_ENABLE_PARTIAL_WRITE;
+ mode |= SSL_MODE_SMALL_BUFFERS; /* lazily allocate record buffers; usually saves
+ * 44k over the default */
+ mode |= SSL_MODE_HANDSHAKE_CUTTHROUGH; /* enable sending of client data as soon as
+ * ClientCCS and ClientFinished are sent */
SSL_CTX_set_mode(ssl_ctx, mode);
if (privatekey != NULL) {
diff --git a/libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java b/libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java
index 46ec1d2..6eca114 100644
--- a/libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java
+++ b/libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java
@@ -34,6 +34,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.security.KeyStore;
@@ -699,14 +700,15 @@
boolean notFinished = true;
SSLSession clientSession = null;
SSLContext clientSslContext = null;
+ String testData = "PING";
private String PASSWORD = "android";
String cipherSuite = (useBKS ? cipherSuiteBKS : cipherSuiteJKS);
/**
- * Implements a test SSL socket server. It wait for a connection on a given
- * port, requests client authentication (if specified), and read 256 bytes
+ * Implements a test SSL socket server. It waits for a connection on a given
+ * port, requests client authentication (if specified), and reads
* from the socket.
*/
class TestServer implements Runnable {
@@ -789,7 +791,7 @@
/**
* Implements a test SSL socket client. It open a connection to localhost on
- * a given port and writes 256 bytes to the socket.
+ * a given port and writes to the socket.
*/
class TestClient implements Runnable {
@@ -822,6 +824,9 @@
SSLSocket socket = (SSLSocket)clientSslContext.getSocketFactory().createSocket();
socket.connect(new InetSocketAddress(port));
+ OutputStream ostream = socket.getOutputStream();
+ ostream.write(testData.getBytes());
+ ostream.flush();
clientSession = socket.getSession();
while (notFinished) {