I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit c941d7bf authored by zzz's avatar zzz
Browse files

HTTPClient: Add config options to pass Via, Referer, and User-Agent through

parent 049d6b2f
No related branches found
No related tags found
No related merge requests found
...@@ -225,6 +225,10 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable ...@@ -225,6 +225,10 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
} }
private static final boolean DEFAULT_GZIP = true; private static final boolean DEFAULT_GZIP = true;
// all default to false
public static final String PROP_REFERER = "i2ptunnel.httpclient.sendReferer";
public static final String PROP_USER_AGENT = "i2ptunnel.httpclient.sendUserAgent";
public static final String PROP_VIA = "i2ptunnel.httpclient.sendVia";
private static long __requestId = 0; private static long __requestId = 0;
protected void clientConnectionRun(Socket s) { protected void clientConnectionRun(Socket s) {
...@@ -465,8 +469,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable ...@@ -465,8 +469,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
line = "Host: " + host; line = "Host: " + host;
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info(getPrefix(requestId) + "Setting host = " + host); _log.info(getPrefix(requestId) + "Setting host = " + host);
} else if (lowercaseLine.startsWith("user-agent: ")) { } else if (lowercaseLine.startsWith("user-agent: ") &&
// always stripped, added back at the end !Boolean.valueOf(getTunnel().getContext().getProperty(PROP_USER_AGENT)).booleanValue()) {
line = null; line = null;
continue; continue;
} else if (lowercaseLine.startsWith("accept")) { } else if (lowercaseLine.startsWith("accept")) {
...@@ -474,12 +478,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable ...@@ -474,12 +478,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
// browser to browser // browser to browser
line = null; line = null;
continue; continue;
} else if (lowercaseLine.startsWith("referer: ")) { } else if (lowercaseLine.startsWith("referer: ") &&
!Boolean.valueOf(getTunnel().getContext().getProperty(PROP_REFERER)).booleanValue()) {
// Shouldn't we be more specific, like accepting in-site referers ? // Shouldn't we be more specific, like accepting in-site referers ?
//line = "Referer: i2p"; //line = "Referer: i2p";
line = null; line = null;
continue; // completely strip the line continue; // completely strip the line
} else if (lowercaseLine.startsWith("via: ")) { } else if (lowercaseLine.startsWith("via: ") &&
!Boolean.valueOf(getTunnel().getContext().getProperty(PROP_VIA)).booleanValue()) {
//line = "Via: i2p"; //line = "Via: i2p";
line = null; line = null;
continue; // completely strip the line continue; // completely strip the line
...@@ -503,7 +509,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable ...@@ -503,7 +509,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
newRequest.append("Accept-Encoding: \r\n"); 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("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"); if (!Boolean.valueOf(getTunnel().getContext().getProperty(PROP_USER_AGENT)).booleanValue())
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;
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment