From 07aa2e280df9dc1e21afcc7762d23f17cb0549f4 Mon Sep 17 00:00:00 2001
From: jrandom <jrandom>
Date: Wed, 5 May 2004 07:29:48 +0000
Subject: [PATCH] strip the Connection, Keep-Alive, and Proxy-Connection
 headers, and always inject Connection: close (this is the cause of the
 intermittent "view $page through squid, try to view eepsite, end up
 requesting through squid" bug)

---
 .../net/i2p/i2ptunnel/I2PTunnelHTTPClient.java   | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java
index 27ceccc50f..1ffc89fa37 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java
@@ -119,6 +119,11 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
                 if (_log.shouldLog(Log.DEBUG))
                     _log.debug("Line=[" + line + "]");
                 
+                if (line.startsWith("Connection: ") || 
+                    line.startsWith("Keep-Alive: ") || 
+                    line.startsWith("Proxy-Connection: "))
+                    continue;
+                
                 if (method == null) { // first line (GET /base64/realaddr)
                     if (_log.shouldLog(Log.DEBUG))
                         _log.debug("Method is null for [" + line + "]");
@@ -182,7 +187,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
                         _log.debug("HOST  :" + host + ":");
                         _log.debug("DEST  :" + destination + ":");
                     }
-
+                    
                 } else {
                     if (line.startsWith("Host: ") && !usingWWWProxy) {
                         line = "Host: " + host;
@@ -190,8 +195,13 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
                             _log.info("Setting host = " + host);
                     }
                 }
-                newRequest.append(line).append("\r\n"); // HTTP spec
-                if (line.length() == 0) break;
+                
+                if (line.length() == 0) {
+                    newRequest.append("Connection: close\r\n\r\n");
+                    break;
+                } else {
+                    newRequest.append(line).append("\r\n"); // HTTP spec
+                }
             }
             if (_log.shouldLog(Log.DEBUG))
                 _log.debug("NewRequest header: [" + newRequest.toString() + "]");
-- 
GitLab