-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: make DebugToolbar smarter about detecting binary/streamed responses #9862
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
Merged
+221
−0
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d008678
feat: add native header detection to DebugToolbar
datamweb 2e5ad15
test: add infrastructure for mocking native header functions
datamweb a191407
test: add test for native header conflict detection
datamweb 2c0846c
test: introduce NativeHeadersStack utility for native header testing
datamweb d8558d2
test: centralize native header function mocks
datamweb 09cad29
test: refactor existing tests to use NativeHeadersStack mocks
datamweb 8acf062
test: refactor NativeHeadersStack to use simplified header simulation
datamweb b4062fb
test: load mock once using setUpBeforeClass()
datamweb 07abd76
refactor: normalize native headers once for cleaner comparisons
datamweb e523bac
refactor: improve readability of hasNativeHeaderConflict method
datamweb b483c8e
docs: update changelog for Toolbar native header detection fix
datamweb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * This file is part of CodeIgniter 4 framework. | ||
| * | ||
| * (c) CodeIgniter Foundation <admin@codeigniter.com> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace CodeIgniter\Test\Utilities; | ||
|
|
||
| /** | ||
| * A utility class for simulating native PHP header handling in unit tests. | ||
| * | ||
| * @internal This class is for testing purposes only. | ||
| */ | ||
| final class NativeHeadersStack | ||
| { | ||
| /** | ||
| * Simulates whether headers have been sent. | ||
| */ | ||
| public static bool $headersSent = false; | ||
|
|
||
| /** | ||
| * Stores the list of headers. | ||
| * | ||
| * @var list<string> | ||
| */ | ||
| public static array $headers = []; | ||
|
|
||
| /** | ||
| * Resets the header stack to defaults. | ||
| * Call this in setUp() to ensure clean state between tests. | ||
| */ | ||
| public static function reset(): void | ||
| { | ||
| self::$headersSent = false; | ||
| self::$headers = []; | ||
| } | ||
|
|
||
| /** | ||
| * Checks if a specific header exists in the stack. | ||
| * | ||
| * @param string $header The exact header string (e.g., 'Content-Type: text/html') | ||
| */ | ||
| public static function has(string $header): bool | ||
| { | ||
| return in_array($header, self::$headers, true); | ||
| } | ||
|
|
||
| /** | ||
| * Adds a header to the stack. | ||
| * | ||
| * @param string $header The header to add (e.g., 'Content-Type: text/html') | ||
| */ | ||
| public static function push(string $header): void | ||
| { | ||
| self::$headers[] = $header; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * This file is part of CodeIgniter 4 framework. | ||
| * | ||
| * (c) CodeIgniter Foundation <admin@codeigniter.com> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace CodeIgniter\Debug; | ||
|
|
||
| use CodeIgniter\Test\Utilities\NativeHeadersStack; | ||
|
|
||
| /** | ||
| * Mock implementation of the native PHP `headers_sent()` function. | ||
| * | ||
| * Instead of checking the actual PHP output buffer, this function | ||
| * checks the static property in NativeHeadersStack. | ||
| * | ||
| * @return bool True if headers are considered sent, false otherwise. | ||
| */ | ||
| function headers_sent(): bool | ||
| { | ||
| return NativeHeadersStack::$headersSent; | ||
| } | ||
|
|
||
| /** | ||
| * Mock implementation of the native PHP `headers_list()` function. | ||
| * | ||
| * Retrieves the array of headers stored in the NativeHeadersStack class | ||
| * rather than the actual headers sent by the server. | ||
| * | ||
| * @return array The list of simulated headers. | ||
| */ | ||
| function headers_list(): array | ||
| { | ||
| return NativeHeadersStack::$headers; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.