summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-08-31 23:07:48 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-08-31 23:07:48 +0200
commit21a87d3c2eeaad6034df505f173c75a0ab804225 (patch)
tree40653c9076fa4c026b601aa43684f69992cdf863 /lib/private
parent2685129184472a308a3ba7730207816151b0ffd7 (diff)
downloadnextcloud-server-21a87d3c2eeaad6034df505f173c75a0ab804225.tar.gz
nextcloud-server-21a87d3c2eeaad6034df505f173c75a0ab804225.zip
No body or content-length for 204 and 304 responses
See: https://tools.ietf.org/html/rfc7230#section-3.3
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/AppFramework/App.php19
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);
+ }
}
}