diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-09-01 15:04:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-01 15:04:09 +0200 |
commit | 7ffed2deae32fb106d245442cb94104242946da1 (patch) | |
tree | e045aa9276bb18b14eea6792621dca6ecd8e3ec4 /lib | |
parent | 59d240c3aaaaa351ecc04c79b7ad6abc8f67363d (diff) | |
parent | 21a87d3c2eeaad6034df505f173c75a0ab804225 (diff) | |
download | nextcloud-server-7ffed2deae32fb106d245442cb94104242946da1.tar.gz nextcloud-server-7ffed2deae32fb106d245442cb94104242946da1.zip |
Merge pull request #1221 from nextcloud/proper_204_304_response
No body or content-length for 204 and 304 responses
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/App.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php index c7670953b4e..5a8099ec7d0 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -30,6 +30,7 @@ namespace OC\AppFramework; use OC\AppFramework\Http\Dispatcher; use OC_App; use OC\AppFramework\DependencyInjection\DIContainer; +use OCP\AppFramework\Http; use OCP\AppFramework\QueryException; use OCP\AppFramework\Http\ICallbackResponse; @@ -142,11 +143,19 @@ class App { ); } - if ($response instanceof ICallbackResponse) { - $response->callback($io); - } else if(!is_null($output)) { - $io->setHeader('Content-Length: ' . strlen($output)); - $io->setOutput($output); + /* + * Status 204 does not have a body and no Content Length + * Status 304 does not have a body and does not need a Content Length + * https://tools.ietf.org/html/rfc7230#section-3.3 + * https://tools.ietf.org/html/rfc7230#section-3.3.2 + */ + if ($httpHeaders !== Http::STATUS_NO_CONTENT && $httpHeaders !== Http::STATUS_NOT_MODIFIED) { + if ($response instanceof ICallbackResponse) { + $response->callback($io); + } else if (!is_null($output)) { + $io->setHeader('Content-Length: ' . strlen($output)); + $io->setOutput($output); + } } } |