#### Can I specify the order of the headers returned with a Laravel response?

I am attempting to add a custom header within a Laravel(8) response called X-Custom which works, but it places it at the top of the header stack as such:

HTTP/1.1 200 OK
Date: Mon, 01 Nov 2021 10:58:44 GMT
Server: Apache/2.4.29 (Ubuntu)
X-Custom: 8675309
Cache-Control: no-cache, private
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
Access-Control-Allow-Origin: *
Content-Length: 13
Content-Type: text/html; charset=UTF-8

Content is here


With low memory devices the earliest header I manage to receive is X-RateLimit-Remaining: 59. So to get the X-Custom header I ideally need it to go on the bottom of the whole stack like so:

HTTP/1.1 200 OK
Date: Mon, 01 Nov 2021 10:58:44 GMT
Server: Apache/2.4.29 (Ubuntu)
Cache-Control: no-cache, private
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
Access-Control-Allow-Origin: *
Content-Length: 13
Content-Type: text/html; charset=UTF-8
X-Custom: 8675309

Content is here


From what I can see Laravel returns the various headers from different files rather than all in one go so I think a simple sort is out of the question.

Is sticking a header on the end achieveable within Laravel’s means?

Source: Laravel