Add downloadable+array query data

This commit is contained in:
Dennis Eichhorn 2019-02-02 23:56:43 +01:00
parent c111b2d432
commit 60685547b6
2 changed files with 25 additions and 1 deletions

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace phpOMS\Message\Http;
use phpOMS\Message\HeaderAbstract;
use phpOMS\System\MimeType;
/**
* Response class.
@ -86,6 +87,25 @@ final class Header extends HeaderAbstract
return true;
}
/**
* Set header as downloadable
*
* @param string $name Download name
* @param string $type Download file type
*
* @return void
*
* @since 1.0.0
*/
public function setDownloadable(string $name, string $type) : void
{
$this->set('Content-Type', MimeType::M_BIN, true);
$this->set('Content-Transfer-Encoding', 'Binary', true);
$this->set(
'Content-disposition', 'attachment; filename="' . $name . '.' . $type . '"'
, true);
}
/**
* Is security header.
*

View File

@ -212,7 +212,11 @@ final class Request extends RequestAbstract
UriFactory::setQuery('/lang', $this->header->getL11n()->getLanguage());
foreach ($this->data as $key => $value) {
UriFactory::setQuery('?' . $key, $value);
if (\is_array($value)) {
UriFactory::setQuery('?' . $key, \implode(',', $value));
} else {
UriFactory::setQuery('?' . $key, $value);
}
}
}