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/, // Rewrite the url to strip out the /i2p/,
// as the naming service accepts B64KEY (but not B64KEY.i2p atm) // as the naming service accepts B64KEY (but not B64KEY.i2p atm)
if ("i2p".equals(host)) { if ("i2p".equals(host)) {
String file = url.getPath(); String file = url.getRawPath();
try { try {
int slash = 1 + file.substring(1).indexOf("/"); int slash = 1 + file.substring(1).indexOf("/");
host = file.substring(1, slash); host = file.substring(1, slash);
_actualURL = "http://" + host + file.substring(slash); _actualURL = "http://" + host + file.substring(slash);
String query = url.getRawQuery();
if (query != null)
_actualURL = _actualURL + '?' + query;
} catch (IndexOutOfBoundsException ioobe) { } catch (IndexOutOfBoundsException ioobe) {
throw new MalformedURLException("Bad /i2p/ format: " + _actualURL); throw new MalformedURLException("Bad /i2p/ format: " + _actualURL);
} }
@ -214,8 +217,8 @@ public class I2PSocketEepGet extends EepGet {
throw ioe; throw ioe;
} }
//String host = url.getHost(); //String host = url.getHost();
String path = url.getPath(); String path = url.getRawPath();
String query = url.getQuery(); String query = url.getRawQuery();
if (query != null) if (query != null)
path = path + '?' + query; path = path + '?' + query;
if (!path.startsWith("/")) if (!path.startsWith("/"))
@ -242,6 +245,8 @@ public class I2PSocketEepGet extends EepGet {
if(!uaOverridden) if(!uaOverridden)
buf.append("User-Agent: " + USER_AGENT + "\r\n"); buf.append("User-Agent: " + USER_AGENT + "\r\n");
buf.append("\r\n"); buf.append("\r\n");
if (_log.shouldDebug())
_log.debug("Request: [" + buf.toString() + "]");
return buf.toString(); return buf.toString();
} }

View File

@ -332,7 +332,7 @@ public class EepGet {
System.exit(1); 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 // if no file specified, eepget scrapes webpage - use domain as name
Pattern slashes = Pattern.compile("/+"); Pattern slashes = Pattern.compile("/+");
@ -1288,8 +1288,8 @@ public class EepGet {
if (host == null || host.length() <= 0) if (host == null || host.length() <= 0)
throw new MalformedURLException("Bad URL, no host"); throw new MalformedURLException("Bad URL, no host");
int port = url.getPort(); int port = url.getPort();
String path = url.getPath(); String path = url.getRawPath();
String query = url.getQuery(); String query = url.getRawQuery();
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Requesting " + _actualURL); _log.debug("Requesting " + _actualURL);
// RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied // 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(); String host = url.getHost();
int port = url.getPort(); int port = url.getPort();
String path = url.getPath(); String path = url.getRawPath();
String query = url.getQuery(); String query = url.getRawQuery();
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Requesting " + _actualURL); _log.debug("Requesting " + _actualURL);
// RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied // 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) if (host == null || host.length() <= 0)
throw new MalformedURLException("Bad URL, no host"); throw new MalformedURLException("Bad URL, no host");
int port = url.getPort(); int port = url.getPort();
String path = url.getPath(); String path = url.getRawPath();
String query = url.getQuery(); String query = url.getRawQuery();
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Requesting " + _actualURL); _log.debug("Requesting " + _actualURL);
// RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied // RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied