Skip to content

Commit 571cc4d

Browse files
authored
add polyfill for send_http_103_early_hints() (#58)
A built-in KPHP function that sends an HTTP 103 header — an intermediate header, in the middle of script execution, before sending 200 OK.
1 parent e201d56 commit 571cc4d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

kphp_polyfills.php

+13
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,19 @@ function vk_dot_product(array $aVector, array $bVector): float {
11001100
return $result;
11011101
}
11021102

1103+
/**
1104+
* Sends an HTTP 103 header — an intermediate header, in the middle of script execution, before sending 200 OK.
1105+
* It's used for Web, to force a browser to preload css/js/other static.
1106+
* Typical usage is: start handling request -> send 103 -> prepare full response -> send 200.
1107+
* Warning! Be sure to test via user-agent whether a client's browser would correctly accept this header.
1108+
* @param string[] $headers
1109+
*/
1110+
function send_http_103_early_hints(array $headers) {
1111+
// in PHP, do nothing;
1112+
// in KPHP, it's a built-in function that sends $headers as passed bypassing response buffers
1113+
// all `header()` calls made before sending 103 remain buffered, they will be applied on 200 response
1114+
}
1115+
11031116

11041117
function likely(bool $value): bool {
11051118
return $value;

0 commit comments

Comments
 (0)