From 8ed34e3edff49c94c51661a7b5167ba3eae26617 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 11 Feb 2014 13:44:37 +0000 Subject: [PATCH] * HTTP client proxy: Don't flush after headers for a POST, so the POST data is included in the SYN packet, to improve speed and reliability of small POSTs --- .../java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java | 11 +++++++++-- history.txt | 5 +++++ router/java/src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java index e9a9a5b212..66351f7493 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java @@ -18,6 +18,7 @@ import javax.net.ssl.SSLException; import net.i2p.I2PAppContext; import net.i2p.client.streaming.I2PSocket; import net.i2p.data.ByteArray; +import net.i2p.data.DataHelper; import net.i2p.util.ByteCache; import net.i2p.util.Clock; import net.i2p.util.I2PAppThread; @@ -137,6 +138,8 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr protected InputStream getSocketIn() throws IOException { return s.getInputStream(); } protected OutputStream getSocketOut() throws IOException { return s.getOutputStream(); } + private static final byte[] POST = { 'P', 'O', 'S', 'T', ' ' }; + @Override public void run() { try { @@ -159,8 +162,12 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr // So we now get a fast return from flush(), and can do it here to save 250 ms. // To make sure we are under the initial window size and don't hang waiting for accept, // only flush if it fits in one message. - if (initialI2PData.length <= 1730) // ConnectionOptions.DEFAULT_MAX_MESSAGE_SIZE - i2pout.flush(); + if (initialI2PData.length <= 1730) { // ConnectionOptions.DEFAULT_MAX_MESSAGE_SIZE + // Don't flush if POST, so we can get POST data into the initial packet + if (initialI2PData.length < 5 || + !DataHelper.eq(POST, 0, initialI2PData, 0, 5)) + i2pout.flush(); + } //} } if (initialSocketData != null) { diff --git a/history.txt b/history.txt index 67672901f3..61b9197639 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,8 @@ +2014-02-11 zzz + * HTTP client proxy: Don't flush after headers for a POST, + so the POST data is included in the SYN packet, + to improve speed and reliability of small POSTs + 2014-02-10 zzz Prop from i2p.i2p.zzz.test2: * Addressbook: Rewrite subscriptions.txt for new default URL diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 282c18b422..0725033fa6 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 2; + public final static long BUILD = 3; /** for example "-test" */ public final static String EXTRA = "";