-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
PHP Version
8.1
CodeIgniter4 Version
4.5.5
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
macOS, Linux
Which server did you use?
apache
Database
mysql Ver 8.3.0 for macos14.2 on arm64 (Homebrew)
What happened?
While implementing a file download feature in a CodeIgniter 4 application, I encountered an issue where multiple Expires and Cache-Control headers were being sent in the HTTP response. This problem occurred despite attempts to explicitly set these headers using the framework's response methods.
Steps to Reproduce
- Create a controller method to serve a file download (e.g., CRL file).
- Use the response object to set custom headers, such as Content-Type, Last-Modified, and Expires.
- Attempt to remove existing headers using $response->removeHeader().
- Observe that multiple Expires and Cache-Control headers are still present in the HTTP response.
Expected Output
Only one instance of each header should be sent in the response, specifically the ones set in the controller method.
Anything else?
As a workaround, the issue was resolved by using native PHP functions (header() and readfile()) to manage headers directly, bypassing CodeIgniter’s response handling. This provided complete control over the headers sent, eliminating the duplication issue.