Page MenuHomePhorge

D25113.1738421400.diff
No OneTemporary

D25113.1738421400.diff

diff --git a/src/aphront/response/AphrontFileResponse.php b/src/aphront/response/AphrontFileResponse.php
--- a/src/aphront/response/AphrontFileResponse.php
+++ b/src/aphront/response/AphrontFileResponse.php
@@ -18,14 +18,38 @@
return $this;
}
+ /**
+ * Set the download filename
+ *
+ * @param $download mixed
+ * @return self
+ */
public function setDownload($download) {
- if (!phutil_nonempty_string($download)) {
- $download = 'untitled';
+ // Known usage:
+ // setDownload(null) -> no download - default
+ // setDownload(false) -> no download - expected
+ // setDownload(true) -> yes named 'untitled' - expected
+ // setDownload('foo.ical') -> yes named 'foo.ical' - expected
+ // setDownload('') -> no download - please avoid
+ // setDownload(0) -> no download - please avoid
+ // setDownload(1) -> yes named 'untitled' - please avoid
+ if ($download) {
+
+ // If you want a download, but you have no idea
+ // about the title, let's choose for you
+ if (!is_string($download)) {
+ $download = 'untitled';
+ }
}
$this->download = $download;
return $this;
}
+ /**
+ * Get the download filename
+ *
+ * @return mixed
+ */
public function getDownload() {
return $this->download;
}
@@ -113,7 +137,7 @@
$headers[] = array('Content-Length', $content_len);
}
- if (strlen($this->getDownload())) {
+ if (phutil_nonempty_string($this->getDownload())) {
$headers[] = array('X-Download-Options', 'noopen');
$filename = $this->getDownload();

File Metadata

Mime Type
text/plain
Expires
Sat, Feb 1, 14:50 (1 w, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1155302
Default Alt Text
D25113.1738421400.diff (1 KB)

Event Timeline