Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5792#discussion_r30265291
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala ---
    @@ -104,6 +108,52 @@ class HistoryServer(
     
       initialize()
     
    +  private[spark] class HistoryServlet(val appId: String) extends 
HttpServlet {
    +
    +    // SPARK-5983 ensure TRACE is not supported
    +    protected override def doTrace(req: HttpServletRequest, res: 
HttpServletResponse): Unit = {
    +      res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED)
    +    }
    +
    +    protected override def doGet(req: HttpServletRequest, res: 
HttpServletResponse): Unit = {
    +      try {
    +        val tempDir = Utils.createTempDir()
    +        Utils.chmod700(tempDir)
    +        provider.getApplicationEventLogs(appId, tempDir) match {
    +          case Some(file) =>
    +            val inStream = new FileInputStream(file)
    +            res.setContentType("application/zip")
    +            res.setHeader("Content-Disposition", s"attachment; 
filename=${file.getName}")
    +            val length = file.length()
    +            if (length <= Integer.MAX_VALUE) {
    +              res.setContentLength(length.toInt)
    +            } else {
    +              res.setHeader("Content-Length", length.toString)
    +            }
    +            val buffer = new Array[Byte](1024 * 1024)
    +            val outputStream = res.getOutputStream
    +            var remaining = true
    +            while (remaining) {
    +              val read = inStream.read(buffer)
    +              if (read != -1) {
    +                outputStream.write(buffer, 0, read)
    +              } else {
    +                remaining = false
    +              }
    +            }
    +            outputStream.flush()
    +
    +          case None =>
    +            res.sendError(HttpServletResponse.SC_NO_CONTENT)
    +        }
    +        Utils.deleteRecursively(tempDir)
    --- End diff --
    
    should this go in a `finally`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to