i2ptunnel, eepget: Capitalize Cache-Control

Change POST throttle response to 429
This commit is contained in:
zzz
2018-02-14 12:54:16 +00:00
parent c48796c0f4
commit 167839b267
27 changed files with 51 additions and 50 deletions

View File

@@ -65,7 +65,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
private final static String ERR_BAD_PROTOCOL =
"HTTP/1.1 405 Bad Method\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -76,7 +76,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
private final static String ERR_LOCALHOST =
"HTTP/1.1 403 Access Denied\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+

View File

@@ -98,7 +98,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_REQUEST_DENIED =
"HTTP/1.1 403 Access Denied\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +
@@ -109,7 +109,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static byte[] ERR_TIMEOUT =
("HTTP/1.1 504 Gateway Timeout\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n\r\n"+
"Cache-Control: no-cache\r\n\r\n"+
"<html><body><H1>I2P ERROR: TIMEOUT</H1>"+
"That Destination was reachable, but timed out getting a "+
"response. This is likely a temporary error, so you should simply "+
@@ -121,7 +121,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_NO_OUTPROXY =
"HTTP/1.1 503 Service Unavailable\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +
@@ -132,7 +132,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_AHELPER_CONFLICT =
"HTTP/1.1 409 Conflict\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +
@@ -149,7 +149,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_AHELPER_NOTFOUND =
"HTTP/1.1 404 Not Found\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +
@@ -161,7 +161,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_AHELPER_NEW =
"HTTP/1.1 409 New Address\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +
@@ -174,7 +174,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_BAD_PROTOCOL =
"HTTP/1.1 403 Bad Protocol\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +
@@ -185,7 +185,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_BAD_URI =
"HTTP/1.1 403 Bad URI\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +
@@ -196,7 +196,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_LOCALHOST =
"HTTP/1.1 403 Access Denied\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +
@@ -206,7 +206,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
private final static String ERR_INTERNAL_SSL =
"HTTP/1.1 403 SSL Rejected\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +

View File

@@ -73,7 +73,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
private static final String ERR_AUTH1 =
"HTTP/1.1 407 Proxy Authentication Required\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.5\r\n" + // try to get a UTF-8-encoded response back for the password
@@ -90,7 +90,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
protected final static String ERR_NO_OUTPROXY =
"HTTP/1.1 503 No Outproxy Configured\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -101,7 +101,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
protected final static String ERR_DESTINATION_UNKNOWN =
"HTTP/1.1 503 Service Unavailable\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n" +

View File

@@ -90,7 +90,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
private final static String ERR_UNAVAILABLE =
"HTTP/1.1 503 Service Unavailable\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -99,22 +99,23 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
"<p>This I2P website is unavailable. It may be down or undergoing maintenance.</p>\n" +
"</body></html>";
// TODO https://stackoverflow.com/questions/16022624/examples-of-http-api-rate-limiting-http-response-headers
private final static String ERR_DENIED =
"HTTP/1.1 403 Denied\r\n"+
"HTTP/1.1 429 Denied\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
"<html><head><title>403 Denied</title></head>\n"+
"<body><h2>403 Denied</h2>\n" +
"<html><head><title>429 Denied</title></head>\n"+
"<body><h2>429 Denied</h2>\n" +
"<p>Denied due to excessive requests. Please try again later.</p>\n" +
"</body></html>";
private final static String ERR_INPROXY =
"HTTP/1.1 403 Denied\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -126,7 +127,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
private final static String ERR_SSL =
"HTTP/1.1 503 Service Unavailable\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -138,7 +139,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
private final static String ERR_REQUEST_URI_TOO_LONG =
"HTTP/1.1 414 Request URI too long\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -149,7 +150,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
private final static String ERR_HEADERS_TOO_LARGE =
"HTTP/1.1 431 Request header fields too large\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -161,7 +162,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
protected final static String ERR_REQUEST_TIMEOUT =
"HTTP/1.1 408 Request timeout\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -172,7 +173,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
private final static String ERR_BAD_REQUEST =
"HTTP/1.1 400 Bad Request\r\n"+
"Content-Type: text/html; charset=iso-8859-1\r\n"+
"Cache-control: no-cache\r\n"+
"Cache-Control: no-cache\r\n"+
"Connection: close\r\n"+
"Proxy-Connection: close\r\n"+
"\r\n"+
@@ -475,7 +476,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
if (_log.shouldLog(Log.WARN))
_log.warn("Refusing POST since peer is throttled: " + peerB32);
try {
// Send a 403, so the user doesn't get an HTTP Proxy error message
// Send a 429, so the user doesn't get an HTTP Proxy error message
// and blame his router or the network.
socket.getOutputStream().write(ERR_DENIED.getBytes("UTF-8"));
} catch (IOException ioe) {}

View File

@@ -25,7 +25,7 @@ class SOCKSServerFactory {
private final static String ERR_REQUEST_DENIED =
"HTTP/1.1 403 Access Denied - This is a SOCKS proxy, not a HTTP proxy\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"\r\n" +
"<html><body><H1>I2P SOCKS PROXY ERROR: REQUEST DENIED</H1>" +
"Your browser is misconfigured. This is a SOCKS proxy, not a HTTP proxy" +

View File

@@ -233,7 +233,7 @@ public class I2PSocketEepGet extends EepGet {
buf.append("-\r\n");
}
buf.append("Accept-Encoding: \r\n" +
"Cache-control: no-cache\r\n" +
"Cache-Control: no-cache\r\n" +
"Pragma: no-cache\r\n" +
"Connection: close\r\n");
boolean uaOverridden = false;

View File

@@ -1362,7 +1362,7 @@ public class EepGet {
buf.append("-\r\n");
}
if (!_allowCaching) {
buf.append("Cache-control: no-cache\r\n" +
buf.append("Cache-Control: no-cache\r\n" +
"Pragma: no-cache\r\n");
}
boolean uaOverridden = false;

View File

@@ -210,7 +210,7 @@ public class PartialEepGet extends EepGet {
buf.append(_fetchSize - 1);
buf.append("\r\n");
buf.append("Cache-control: no-cache\r\n" +
buf.append("Cache-Control: no-cache\r\n" +
"Pragma: no-cache\r\n" +
"Accept-Encoding: \r\n" +
"Connection: close\r\n");

View File

@@ -1,7 +1,7 @@
HTTP/1.1 409 Conflict
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,7 +1,7 @@
HTTP/1.1 409 New Address
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 409 Bad Helper
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -2,7 +2,7 @@ HTTP/1.1 407 Proxy Authorization Required
Content-Type: text/html; charset=UTF-8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.5
Proxy-Authenticate: Basic realm="I2P HTTP Proxy"
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 403 Bad URI
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 403 Request Denied
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 400 Destination Not Found
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,7 +1,7 @@
HTTP/1.1 500 Domain Not Found
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 403 Access Denied
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 503 No Outproxy Configured
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 403 Bad Protocol
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 403 Connection Reset
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close

View File

@@ -1,6 +1,6 @@
HTTP/1.1 403 Connection Reset
Content-Type: text/html; charset=UTF-8
Cache-control: no-cache
Cache-Control: no-cache
Connection: close
Proxy-Connection: close