EepGet: Fixes after URL to URI conversion

This commit is contained in:
zzz
2015-11-21 17:37:56 +00:00
parent 7649132259
commit d30c1ec319
4 changed files with 15 additions and 10 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -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

View File

@ -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