HyukjinKwon commented on code in PR #58640:
URL: https://github.com/apache/spark/pull/58640#discussion_r3963569133
##########
core/src/main/scala/org/apache/spark/ui/JettyUtils.scala:
##########
@@ -167,6 +200,44 @@ private[spark] object JettyUtils extends Logging {
createServletHandler(srcPath, servlet, basePath)
}
+ /**
+ * True when the request identifies itself as a prefetch rather than a
deliberate user
+ * navigation: Chrome and derivatives send "Sec-Purpose: prefetch" (or the
older
+ * "Purpose: prefetch", and compound values such as "prefetch;prerender"),
and Firefox
+ * sends "X-Moz: prefetch". State-changing endpoints reject these so that a
link
+ * prefetcher cannot trigger the action: a prefetch of a kill link must not
kill.
+ */
+ private[spark] def isPrefetchRequest(request: HttpServletRequest): Boolean =
{
+ val purpose = Option(request.getHeader("Sec-Purpose"))
+ .orElse(Option(request.getHeader("Purpose")))
+ purpose.exists(_.toLowerCase(Locale.ROOT).contains("prefetch")) ||
+ request.getHeader("X-Moz") != null
Review Comment:
Minor consistency nit: `request.getHeader("X-Moz") != null` treats any
`X-Moz` value as a prefetch, whereas the `Sec-Purpose`/`Purpose` checks above
require the value to contain `"prefetch"`. Matching `"prefetch"` here too would
keep the three branches consistent — e.g. fold `X-Moz` into the same
`.exists(_.toLowerCase(Locale.ROOT).contains("prefetch"))` test. In practice
`X-Moz` is only ever `prefetch`, so this is cosmetic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]