Why is addContentLengthHeader false by default?


#1

Hi there,

I’m wondering why addContentLengthHeader is false by default, when creating a new Slim project via:
composer create-project slim/slim-skeleton first-slim-app

It is also false in the very beginnig of the docs:
https://www.slimframework.com/docs/#how-does-it-work

So, does it make performance overhead?
Or is it maybe buggy?

Actually, I need Content-Length on the client side, but only for certain requests. (I need this to be able to show the download progress).
So, should I optimize addContentLengthHeader, and only set it true for those requests really needing it?

Thank you very much!


#2

Replying just in case someone stumbles upon this after weeks of hair-pulling like me. I am using PHP-DI’s Slim-Bridge and the default configuration sets addContentLengthHeader to true.

The issue is I haven’t been able to enable output compression when the Content-Length header is set, either with PHP’s ob_gzhandler or zlib.output_compression or Apache’s AddOutputFilterByType and Filter* directives.

Disabling this setting by adding a "settings.addContentLengthHeader" => false in my definitions array did the trick.