-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add header_register_callback
builtin support
#1101
Conversation
e556b80
to
6759d6d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main idea behind header_register_callback
is to give opportunity to modify headers before any output is sent.
Output can be sent in the middle of script in some cases. Off the top of my head, I can remember at least 2 such cases:
f$flush
There's a test for that case, but for some reason it's not correctf$send_http_103_early_hints
Now these cases are skipped, and we invoke callback only in the end of the script. Now it behaves just like register_shutdown_function
and it's incorrect
For example:
<?php
function main() {
header_register_callback(function() {
fprintf(STDERR, "header_callback invoked\n");
header("Qwerty: hello");
});
fprintf(STDERR, "before flush()\n");
echo "111111111\n";
flush();
echo "222222222\n";
fprintf(STDERR, "after flush()\n");
}
main();
Expected behaviour here is to have Qwerty: hello
response header, but that's not really the case.
Let's do the following:
- find and fix all skipped cases like that
- add test with callback, which sends some RPC to check
swapcontext
correctness
a4ec3eb
to
3ad05b8
Compare
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
3ad05b8
to
062d5f0
Compare
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
Add compatible with PHP 7.4.0 support of header_register_callback builtin.
Related issues: KPHP-1860
NOTE:
f$send_http_103_early_hints
shouldn't be a cause of callback invocation