Setting custom content-length header


#1

Hello

I have an api with a endpoint /posts
this endpoint lists all posts as json objects. each post consists of
title
content
images

All the images are URLs to the actual location of the file.

So what I want to do:
I need the content-length header to show the size of the body including the size of all images of the post. How can I achieve this?
When I manual set the content-length header to an arbitrary value bigger than the actual content-length, the client still receives the actual content-length but not the custom content-length (Is it slim or my webserver?)
Strangely setting a custom content-length smaller than the actual content-length works. and the client receives the custom content-length.


#2

I expect that this is your web server. Slim will set the Content-Length header if you haven’t already set it yourself, but it won’t change whatever you’ve set it to.