Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Multiple Expires and Last-Modified Headers in File Download Response #9234

Open
ToastStudios opened this issue Oct 23, 2024 · 1 comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@ToastStudios
Copy link

PHP Version

8.1

CodeIgniter4 Version

4.5.2

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 Last-Modified 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

  1. Create a controller method to serve a file download (e.g., CRL file).
  2. Use the response object to set custom headers, such as Content-Type, Last-Modified, and Expires.
  3. Attempt to remove existing headers using $response->removeHeader().
  4. Observe that multiple Expires and Last-Modified 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.

@ToastStudios ToastStudios added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 23, 2024
@michalsn
Copy link
Member

Can you provide a sample code so we can reproduce the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

2 participants