Merge pull request #24706 from nextcloud/bugfix/noid/log-error-on-setting-custom-headers-on-no-content-responses

Log an error when setting a custom header on "Not Modified" responses
This commit is contained in:
Roeland Jago Douma 2020-12-16 10:28:09 +01:00 committed by GitHub
commit 7a77493038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -38,6 +38,8 @@ namespace OCP\AppFramework\Http;
use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use Psr\Log\LoggerInterface;
/**
* Base class for responses. Also used to just send headers.
@ -203,6 +205,18 @@ class Response {
// to be able to reliably check for security
// headers
if ($this->status === Http::STATUS_NOT_MODIFIED
&& stripos($name, 'x-') === 0) {
/** @var IConfig $config */
$config = \OC::$server->get(IConfig::class);
if ($config->getSystemValueBool('debug', false)) {
\OC::$server->get(LoggerInterface::class)->error(
'Setting a custom header on a 204 or 304 is not supported'
);
}
}
if (is_null($value)) {
unset($this->headers[$name]);
} else {