summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMark Macdonald2011-05-18 17:11:22 (EDT)
committer Boris Bokowski2011-05-19 10:46:29 (EDT)
commita5805f83af355663e0a0f835737a9a90d8b9bfed (patch)
tree6d80b8325a75c59f89362a8426c7fc3ff88b3143
parent2b5b204fd1409c9553023ee89f85941d64fdc909 (diff)
downloadorg.eclipse.orion.server-a5805f83af355663e0a0f835737a9a90d8b9bfed.zip
org.eclipse.orion.server-a5805f83af355663e0a0f835737a9a90d8b9bfed.tar.gz
org.eclipse.orion.server-a5805f83af355663e0a0f835737a9a90d8b9bfed.tar.bz2
Bug 346139: self-hosted site launching not workingv20110516-1749-fixes-20110519-1147
- avoid infinite loops of proxy requests https://bugs.eclipse.org/bugs/show_bug.cgi?id=346139
-rw-r--r--bundles/org.eclipse.orion.server.hosting/src/org/eclipse/orion/internal/server/hosting/RemoteURLProxyServlet.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/bundles/org.eclipse.orion.server.hosting/src/org/eclipse/orion/internal/server/hosting/RemoteURLProxyServlet.java b/bundles/org.eclipse.orion.server.hosting/src/org/eclipse/orion/internal/server/hosting/RemoteURLProxyServlet.java
index 343b44f..53b0c9b 100644
--- a/bundles/org.eclipse.orion.server.hosting/src/org/eclipse/orion/internal/server/hosting/RemoteURLProxyServlet.java
+++ b/bundles/org.eclipse.orion.server.hosting/src/org/eclipse/orion/internal/server/hosting/RemoteURLProxyServlet.java
@@ -124,6 +124,24 @@ public class RemoteURLProxyServlet extends ProxyServlet {
if (!xForwardedFor)
connection.addRequestProperty("X-Forwarded-For", request.getRemoteAddr());
+ // Bug 346139: prevent an infinite proxy loop by decrementing the Max-Forwards header
+ Enumeration maxForwardsHeaders = request.getHeaders("Max-Forwards");
+ String maxForwardsHeader = null;
+ while (maxForwardsHeaders.hasMoreElements()) {
+ maxForwardsHeader = (String) maxForwardsHeaders.nextElement();
+ }
+ int maxForwards = 5;
+ try {
+ maxForwards = Math.max(0, Integer.parseInt(maxForwardsHeader));
+ } catch (NumberFormatException e) {
+ // Use default
+ }
+ if (maxForwards-- < 1) {
+ response.sendError(HttpURLConnection.HTTP_BAD_GATEWAY, "Max-Forwards exceeded");
+ return;
+ }
+ connection.addRequestProperty("Max-Forwards", "" + maxForwards);
+
// a little bit of cache control
String cache_control = request.getHeader("Cache-Control");
if (cache_control != null && (cache_control.indexOf("no-cache") >= 0 || cache_control.indexOf("no-store") >= 0))