From d30c1ec3191c600e8530eae382a918ec8d5211ba Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 21 Nov 2015 17:37:56 +0000 Subject: [PATCH] EepGet: Fixes after URL to URI conversion --- .../src/net/i2p/client/streaming/I2PSocketEepGet.java | 11 ++++++++--- core/java/src/net/i2p/util/EepGet.java | 6 +++--- core/java/src/net/i2p/util/EepHead.java | 4 ++-- core/java/src/net/i2p/util/PartialEepGet.java | 4 ++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java index 1d3c77a16c..73ede8bb05 100644 --- a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java +++ b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java @@ -124,11 +124,14 @@ public class I2PSocketEepGet extends EepGet { // Rewrite the url to strip out the /i2p/, // as the naming service accepts B64KEY (but not B64KEY.i2p atm) if ("i2p".equals(host)) { - String file = url.getPath(); + String file = url.getRawPath(); try { int slash = 1 + file.substring(1).indexOf("/"); host = file.substring(1, slash); _actualURL = "http://" + host + file.substring(slash); + String query = url.getRawQuery(); + if (query != null) + _actualURL = _actualURL + '?' + query; } catch (IndexOutOfBoundsException ioobe) { throw new MalformedURLException("Bad /i2p/ format: " + _actualURL); } @@ -214,8 +217,8 @@ public class I2PSocketEepGet extends EepGet { throw ioe; } //String host = url.getHost(); - String path = url.getPath(); - String query = url.getQuery(); + String path = url.getRawPath(); + String query = url.getRawQuery(); if (query != null) path = path + '?' + query; if (!path.startsWith("/")) @@ -242,6 +245,8 @@ public class I2PSocketEepGet extends EepGet { if(!uaOverridden) buf.append("User-Agent: " + USER_AGENT + "\r\n"); buf.append("\r\n"); + if (_log.shouldDebug()) + _log.debug("Request: [" + buf.toString() + "]"); return buf.toString(); } diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index d9d9ba6fec..19816bb41d 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -332,7 +332,7 @@ public class EepGet { System.exit(1); } - String path = nameURL.getPath(); // discard any URI queries + String path = nameURL.getRawPath(); // discard any URI queries // if no file specified, eepget scrapes webpage - use domain as name Pattern slashes = Pattern.compile("/+"); @@ -1288,8 +1288,8 @@ public class EepGet { if (host == null || host.length() <= 0) throw new MalformedURLException("Bad URL, no host"); int port = url.getPort(); - String path = url.getPath(); - String query = url.getQuery(); + String path = url.getRawPath(); + String query = url.getRawQuery(); if (_log.shouldLog(Log.DEBUG)) _log.debug("Requesting " + _actualURL); // RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied diff --git a/core/java/src/net/i2p/util/EepHead.java b/core/java/src/net/i2p/util/EepHead.java index ef6f5067dd..3c53314937 100644 --- a/core/java/src/net/i2p/util/EepHead.java +++ b/core/java/src/net/i2p/util/EepHead.java @@ -265,8 +265,8 @@ public class EepHead extends EepGet { } String host = url.getHost(); int port = url.getPort(); - String path = url.getPath(); - String query = url.getQuery(); + String path = url.getRawPath(); + String query = url.getRawQuery(); if (_log.shouldLog(Log.DEBUG)) _log.debug("Requesting " + _actualURL); // RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied diff --git a/core/java/src/net/i2p/util/PartialEepGet.java b/core/java/src/net/i2p/util/PartialEepGet.java index 4d0967763a..9d853137d5 100644 --- a/core/java/src/net/i2p/util/PartialEepGet.java +++ b/core/java/src/net/i2p/util/PartialEepGet.java @@ -180,8 +180,8 @@ public class PartialEepGet extends EepGet { if (host == null || host.length() <= 0) throw new MalformedURLException("Bad URL, no host"); int port = url.getPort(); - String path = url.getPath(); - String query = url.getQuery(); + String path = url.getRawPath(); + String query = url.getRawQuery(); if (_log.shouldLog(Log.DEBUG)) _log.debug("Requesting " + _actualURL); // RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied -- GitLab