forked from I2P_Developers/i2p.i2p
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.
This commit is contained in:
@ -444,8 +444,13 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
|||||||
boolean gzip = DEFAULT_GZIP;
|
boolean gzip = DEFAULT_GZIP;
|
||||||
if (ok != null)
|
if (ok != null)
|
||||||
gzip = Boolean.valueOf(ok).booleanValue();
|
gzip = Boolean.valueOf(ok).booleanValue();
|
||||||
if (gzip)
|
if (gzip) {
|
||||||
newRequest.append("Accept-Encoding: x-i2p-gzip\r\n");
|
// 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("User-Agent: MYOB/6.66 (AN/ON)\r\n");
|
||||||
newRequest.append("Connection: close\r\n\r\n");
|
newRequest.append("Connection: close\r\n\r\n");
|
||||||
break;
|
break;
|
||||||
|
@ -75,7 +75,11 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
// we keep the enc sent by the browser before clobbering it, since it may have
|
// we keep the enc sent by the browser before clobbering it, since it may have
|
||||||
// been x-i2p-gzip
|
// been x-i2p-gzip
|
||||||
String enc = headers.getProperty("Accept-encoding");
|
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 = formatHeaders(headers, command);
|
||||||
|
|
||||||
//String modifiedHeader = getModifiedHeader(socket);
|
//String modifiedHeader = getModifiedHeader(socket);
|
||||||
@ -97,8 +101,12 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
allowGZIP = false;
|
allowGZIP = false;
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("HTTP server encoding header: " + enc);
|
_log.info("HTTP server encoding header: " + enc + "/" + altEnc);
|
||||||
if ( allowGZIP && (enc != null) && (enc.indexOf("x-i2p-gzip") >= 0) ) {
|
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");
|
I2PThread req = new I2PThread(new CompressedRequestor(s, socket, modifiedHeader), "http compressor");
|
||||||
req.start();
|
req.start();
|
||||||
} else {
|
} else {
|
||||||
@ -297,6 +305,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
String value = buf.substring(split+2); // ": "
|
String value = buf.substring(split+2); // ": "
|
||||||
if ("Accept-encoding".equalsIgnoreCase(name))
|
if ("Accept-encoding".equalsIgnoreCase(name))
|
||||||
name = "Accept-encoding";
|
name = "Accept-encoding";
|
||||||
|
else if ("X-Accept-encoding".equalsIgnoreCase(name))
|
||||||
|
name = "X-Accept-encoding";
|
||||||
headers.setProperty(name, value);
|
headers.setProperty(name, value);
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Read the header [" + name + "] = [" + value + "]");
|
_log.debug("Read the header [" + name + "] = [" + value + "]");
|
||||||
|
11
history.txt
11
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
|
* 2005-11-15 0.6.1.5 released
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RouterVersion {
|
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 String VERSION = "0.6.1.5";
|
||||||
public final static long BUILD = 0;
|
public final static long BUILD = 1;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||||
System.out.println("Router ID: " + RouterVersion.ID);
|
System.out.println("Router ID: " + RouterVersion.ID);
|
||||||
|
Reference in New Issue
Block a user