forked from I2P_Developers/i2p.i2p
* EepGet:
- Fix URL when not proxied to conform to RFC 2616 - Add port to Host header to conform to RFC 2616
This commit is contained in:
@@ -1087,24 +1087,36 @@ public class EepGet {
|
|||||||
if ( (_postData != null) && (_postData.length() > 0) )
|
if ( (_postData != null) && (_postData.length() > 0) )
|
||||||
post = true;
|
post = true;
|
||||||
URL url = new URL(_actualURL);
|
URL url = new URL(_actualURL);
|
||||||
String proto = url.getProtocol();
|
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
int port = url.getPort();
|
int port = url.getPort();
|
||||||
String path = url.getPath();
|
String path = url.getPath();
|
||||||
String query = url.getQuery();
|
String query = url.getQuery();
|
||||||
if (query != null)
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
path = path + '?' + query;
|
_log.debug("Requesting " + _actualURL);
|
||||||
if (!path.startsWith("/"))
|
// RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied
|
||||||
path = "/" + path;
|
String urlToSend;
|
||||||
if ( (port == 80) || (port == 443) || (port <= 0) ) path = proto + "://" + host + path;
|
if (_shouldProxy) {
|
||||||
else path = proto + "://" + host + ":" + port + path;
|
urlToSend = _actualURL;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Requesting " + path);
|
if ((path == null || path.length()<= 0) &&
|
||||||
if (post) {
|
(query == null || query.length()<= 0))
|
||||||
buf.append("POST ").append(_actualURL).append(" HTTP/1.1\r\n");
|
urlToSend += "/";
|
||||||
} else {
|
} else {
|
||||||
buf.append("GET ").append(_actualURL).append(" HTTP/1.1\r\n");
|
urlToSend = path;
|
||||||
|
if (urlToSend == null || urlToSend.length()<= 0)
|
||||||
|
urlToSend = "/";
|
||||||
|
if (query != null)
|
||||||
|
urlToSend += '?' + query;
|
||||||
}
|
}
|
||||||
buf.append("Host: ").append(url.getHost()).append("\r\n");
|
if (post) {
|
||||||
|
buf.append("POST ").append(urlToSend).append(" HTTP/1.1\r\n");
|
||||||
|
} else {
|
||||||
|
buf.append("GET ").append(urlToSend).append(" HTTP/1.1\r\n");
|
||||||
|
}
|
||||||
|
// RFC 2616 sec 5.1.2 - host + port (NOT authority, which includes userinfo)
|
||||||
|
buf.append("Host: ").append(host);
|
||||||
|
if (port >= 0)
|
||||||
|
buf.append(':').append(port);
|
||||||
|
buf.append("\r\n");
|
||||||
if (_alreadyTransferred > 0) {
|
if (_alreadyTransferred > 0) {
|
||||||
buf.append("Range: bytes=");
|
buf.append("Range: bytes=");
|
||||||
buf.append(_alreadyTransferred);
|
buf.append(_alreadyTransferred);
|
||||||
|
@@ -183,20 +183,32 @@ public class EepHead extends EepGet {
|
|||||||
protected String getRequest() throws IOException {
|
protected String getRequest() throws IOException {
|
||||||
StringBuilder buf = new StringBuilder(512);
|
StringBuilder buf = new StringBuilder(512);
|
||||||
URL url = new URL(_actualURL);
|
URL url = new URL(_actualURL);
|
||||||
String proto = url.getProtocol();
|
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
int port = url.getPort();
|
int port = url.getPort();
|
||||||
String path = url.getPath();
|
String path = url.getPath();
|
||||||
String query = url.getQuery();
|
String query = url.getQuery();
|
||||||
if (query != null)
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
path = path + "?" + query;
|
_log.debug("Requesting " + _actualURL);
|
||||||
if (!path.startsWith("/"))
|
// RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied
|
||||||
path = "/" + path;
|
String urlToSend;
|
||||||
if ( (port == 80) || (port == 443) || (port <= 0) ) path = proto + "://" + host + path;
|
if (_shouldProxy) {
|
||||||
else path = proto + "://" + host + ":" + port + path;
|
urlToSend = _actualURL;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Requesting " + path);
|
if ((path == null || path.length()<= 0) &&
|
||||||
buf.append("HEAD ").append(_actualURL).append(" HTTP/1.1\r\n");
|
(query == null || query.length()<= 0))
|
||||||
buf.append("Host: ").append(url.getHost()).append("\r\n");
|
urlToSend += "/";
|
||||||
|
} else {
|
||||||
|
urlToSend = path;
|
||||||
|
if (urlToSend == null || urlToSend.length()<= 0)
|
||||||
|
urlToSend = "/";
|
||||||
|
if (query != null)
|
||||||
|
urlToSend += '?' + query;
|
||||||
|
}
|
||||||
|
buf.append("HEAD ").append(urlToSend).append(" HTTP/1.1\r\n");
|
||||||
|
// RFC 2616 sec 5.1.2 - host + port (NOT authority, which includes userinfo)
|
||||||
|
buf.append("Host: ").append(host);
|
||||||
|
if (port >= 0)
|
||||||
|
buf.append(':').append(port);
|
||||||
|
buf.append("\r\n");
|
||||||
buf.append("Accept-Encoding: \r\n");
|
buf.append("Accept-Encoding: \r\n");
|
||||||
// This will be replaced if we are going through I2PTunnelHTTPClient
|
// This will be replaced if we are going through I2PTunnelHTTPClient
|
||||||
buf.append("User-Agent: " + USER_AGENT + "\r\n");
|
buf.append("User-Agent: " + USER_AGENT + "\r\n");
|
||||||
|
@@ -95,20 +95,32 @@ public class PartialEepGet extends EepGet {
|
|||||||
protected String getRequest() throws IOException {
|
protected String getRequest() throws IOException {
|
||||||
StringBuilder buf = new StringBuilder(2048);
|
StringBuilder buf = new StringBuilder(2048);
|
||||||
URL url = new URL(_actualURL);
|
URL url = new URL(_actualURL);
|
||||||
String proto = url.getProtocol();
|
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
int port = url.getPort();
|
int port = url.getPort();
|
||||||
String path = url.getPath();
|
String path = url.getPath();
|
||||||
String query = url.getQuery();
|
String query = url.getQuery();
|
||||||
if (query != null)
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
path = path + '?' + query;
|
_log.debug("Requesting " + _actualURL);
|
||||||
if (!path.startsWith("/"))
|
// RFC 2616 sec 5.1.2 - full URL if proxied, absolute path only if not proxied
|
||||||
path = "/" + path;
|
String urlToSend;
|
||||||
if ( (port == 80) || (port == 443) || (port <= 0) ) path = proto + "://" + host + path;
|
if (_shouldProxy) {
|
||||||
else path = proto + "://" + host + ":" + port + path;
|
urlToSend = _actualURL;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Requesting " + path);
|
if ((path == null || path.length()<= 0) &&
|
||||||
buf.append("GET ").append(_actualURL).append(" HTTP/1.1\r\n");
|
(query == null || query.length()<= 0))
|
||||||
buf.append("Host: ").append(url.getHost()).append("\r\n");
|
urlToSend += "/";
|
||||||
|
} else {
|
||||||
|
urlToSend = path;
|
||||||
|
if (urlToSend == null || urlToSend.length()<= 0)
|
||||||
|
urlToSend = "/";
|
||||||
|
if (query != null)
|
||||||
|
urlToSend += '?' + query;
|
||||||
|
}
|
||||||
|
buf.append("GET ").append(urlToSend).append(" HTTP/1.1\r\n");
|
||||||
|
// RFC 2616 sec 5.1.2 - host + port (NOT authority, which includes userinfo)
|
||||||
|
buf.append("Host: ").append(host);
|
||||||
|
if (port >= 0)
|
||||||
|
buf.append(':').append(port);
|
||||||
|
buf.append("\r\n");
|
||||||
buf.append("Range: bytes=");
|
buf.append("Range: bytes=");
|
||||||
buf.append(_alreadyTransferred);
|
buf.append(_alreadyTransferred);
|
||||||
buf.append('-');
|
buf.append('-');
|
||||||
|
@@ -1,3 +1,8 @@
|
|||||||
|
2013-01-31 zzz
|
||||||
|
* EepGet:
|
||||||
|
- Fix URL when not proxied to conform to RFC 2616
|
||||||
|
- Add port to Host header to conform to RFC 2616
|
||||||
|
|
||||||
2013-01-29 zzz
|
2013-01-29 zzz
|
||||||
* Console: Catch IllegalStateException storing nonces (ticket #852)
|
* Console: Catch IllegalStateException storing nonces (ticket #852)
|
||||||
* Translations:
|
* Translations:
|
||||||
|
@@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 8;
|
public final static long BUILD = 9;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user