| 604 | |
| 605 | |
| 606 | http::Response MemoryProfiler::DiskArtifact::asHttp() const |
| 607 | { |
| 608 | // If we get here, we want to serve the file that *should* be on disk. |
| 609 | // Verify that it still exists before attempting to serve it. |
| 610 | // |
| 611 | // TODO(bevers): Store a checksum and verify that it matches. |
| 612 | if (!os::stat::isfile(path)) { |
| 613 | return http::BadRequest("Requested file was deleted from local disk.\n"); |
| 614 | } |
| 615 | |
| 616 | process::http::OK response; |
| 617 | response.type = response.PATH; |
| 618 | response.path = path; |
| 619 | response.headers["Content-Type"] = "application/octet-stream"; |
| 620 | response.headers["Content-Disposition"] = |
| 621 | strings::format("attachment; filename=%s", path).get(); |
| 622 | |
| 623 | return std::move(response); |
| 624 | } |
| 625 | |
| 626 | |
| 627 | Try<MemoryProfiler::DiskArtifact> MemoryProfiler::DiskArtifact::create( |
no test coverage detected