From 7625c88e15cc4b791759be40ca560b7b98a8e2cc Mon Sep 17 00:00:00 2001 From: Rohit Agarwal Date: Mon, 7 Dec 2015 14:32:19 -0800 Subject: [PATCH 1/2] SPARK-12186: Send the complete request URI including the query string when redirecting. --- .../org/apache/spark/deploy/history/HistoryServer.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala b/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala index d4f327cc588f..aee56cc2390b 100644 --- a/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala +++ b/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala @@ -103,7 +103,11 @@ class HistoryServer( // Note we don't use the UI retrieved from the cache; the cache loader above will register // the app's UI, and all we need to do is redirect the user to the same URI that was // requested, and the proper data should be served at that point. - res.sendRedirect(res.encodeRedirectURL(req.getRequestURI())) + if (req.getQueryString == null) { + res.sendRedirect(res.encodeRedirectURL(req.getRequestURI())) + } else { + res.sendRedirect(res.encodeRedirectURL(req.getRequestURI + "?" + req.getQueryString)) + } } // SPARK-5983 ensure TRACE is not supported From 780ee624b23703b11c4c90b74b80af8202abd21e Mon Sep 17 00:00:00 2001 From: Rohit Agarwal Date: Wed, 16 Dec 2015 10:56:19 -0800 Subject: [PATCH 2/2] SPARK-12186: Add a comment explaining the changes. Convert it to a one-liner. --- .../org/apache/spark/deploy/history/HistoryServer.scala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala b/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala index aee56cc2390b..f31fef0eccc3 100644 --- a/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala +++ b/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala @@ -103,11 +103,9 @@ class HistoryServer( // Note we don't use the UI retrieved from the cache; the cache loader above will register // the app's UI, and all we need to do is redirect the user to the same URI that was // requested, and the proper data should be served at that point. - if (req.getQueryString == null) { - res.sendRedirect(res.encodeRedirectURL(req.getRequestURI())) - } else { - res.sendRedirect(res.encodeRedirectURL(req.getRequestURI + "?" + req.getQueryString)) - } + // Also, make sure that the redirect url contains the query string present in the request. + val requestURI = req.getRequestURI + Option(req.getQueryString).map("?" + _).getOrElse("") + res.sendRedirect(res.encodeRedirectURL(requestURI)) } // SPARK-5983 ensure TRACE is not supported