Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ class HistoryServer(
// attempt ID (separated by a slash).
val parts = Option(req.getPathInfo()).getOrElse("").split("/")
if (parts.length < 2) {
res.sendError(HttpServletResponse.SC_BAD_REQUEST,
s"Unexpected path info in request (URI = ${req.getRequestURI()}")
return
res.sendRedirect("/")
}

val appId = parts(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,19 @@ class HistoryServerSuite extends SparkFunSuite with BeforeAndAfter with Matchers
val actualContentType = conn.getContentType
assert(actualContentType === expectedContentType)
}

test("Redirect to the root page when accessed to /history/") {
val port = server.boundPort
val url = new URL(s"http://localhost:$port/history/")
val conn = url.openConnection().asInstanceOf[HttpURLConnection]
conn.setRequestMethod("GET")
conn.setUseCaches(false)
conn.setDefaultUseCaches(false)
conn.setInstanceFollowRedirects(false)
conn.connect()
assert(conn.getResponseCode === 302)
assert(conn.getHeaderField("Location") === s"http://localhost:$port/")
}
}

object HistoryServerSuite {
Expand Down