diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index ce655f17b..938aae6dc 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -444,8 +444,13 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable boolean gzip = DEFAULT_GZIP; if (ok != null) gzip = Boolean.valueOf(ok).booleanValue(); - if (gzip) - newRequest.append("Accept-Encoding: x-i2p-gzip\r\n"); + if (gzip) { + // according to rfc2616 s14.3, this *should* force identity, even if + // an explicit q=0 for gzip doesn't. tested against orion.i2p, and it + // seems to work. + newRequest.append("Accept-Encoding: \r\n"); + newRequest.append("X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n"); + } newRequest.append("User-Agent: MYOB/6.66 (AN/ON)\r\n"); newRequest.append("Connection: close\r\n\r\n"); break; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java index 8c1227eac..094145f66 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java @@ -75,7 +75,11 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { // we keep the enc sent by the browser before clobbering it, since it may have // been x-i2p-gzip String enc = headers.getProperty("Accept-encoding"); - headers.setProperty("Accept-encoding", "identity;q=1, *;q=0"); + String altEnc = headers.getProperty("X-Accept-encoding"); + + // according to rfc2616 s14.3, this *should* force identity, even if + // "identity;q=1, *;q=0" didn't. + headers.setProperty("Accept-encoding", ""); String modifiedHeader = formatHeaders(headers, command); //String modifiedHeader = getModifiedHeader(socket); @@ -97,8 +101,12 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { allowGZIP = false; } if (_log.shouldLog(Log.INFO)) - _log.info("HTTP server encoding header: " + enc); - if ( allowGZIP && (enc != null) && (enc.indexOf("x-i2p-gzip") >= 0) ) { + _log.info("HTTP server encoding header: " + enc + "/" + altEnc); + boolean useGZIP = ( (enc != null) && (enc.indexOf("x-i2p-gzip") >= 0) ); + if ( (!useGZIP) && (altEnc != null) && (altEnc.indexOf("x-i2p-gzip") >= 0) ) + useGZIP = true; + + if (allowGZIP && useGZIP) { I2PThread req = new I2PThread(new CompressedRequestor(s, socket, modifiedHeader), "http compressor"); req.start(); } else { @@ -297,6 +305,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { String value = buf.substring(split+2); // ": " if ("Accept-encoding".equalsIgnoreCase(name)) name = "Accept-encoding"; + else if ("X-Accept-encoding".equalsIgnoreCase(name)) + name = "X-Accept-encoding"; headers.setProperty(name, value); if (_log.shouldLog(Log.DEBUG)) _log.debug("Read the header [" + name + "] = [" + value + "]"); diff --git a/history.txt b/history.txt index a509fc69b..2af5c0032 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,13 @@ -$Id: history.txt,v 1.321 2005/11/14 19:24:36 jrandom Exp $ +$Id: history.txt,v 1.322 2005/11/15 22:20:22 jrandom Exp $ + +2005-11-16 jrandom + * More aggressive I2PTunnel content encoding munging to work around some + rare HTTP behavior (ignoring q values on Accept-encoding, using gzip + even when only identity is specified, etc). I2PTunnelHTTPServer now + sends "Accept-encoding: \r\n" plus "X-Accept-encoding: x-i2p-gzip\r\n", + and I2PTunnelHTTPServer handles x-i2p-gzip in either the Accept-encoding + or X-Accept-encoding headers. Eepsite operators who do not know to + check for X-Accept-encoding will simply use the identity encoding. * 2005-11-15 0.6.1.5 released diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 633464838..0e8b82f41 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.289 $ $Date: 2005/11/15 01:38:00 $"; + public final static String ID = "$Revision: 1.290 $ $Date: 2005/11/15 22:20:22 $"; public final static String VERSION = "0.6.1.5"; - public final static long BUILD = 0; + public final static long BUILD = 1; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID);