-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Description
The following code:
<?php
stream_context_set_default([
'http' => array(
'user_agent' => 'dummy',
)
]);
$f = fopen("http://example.com", 'r');
var_dump(stream_get_contents($f));
$f = gzopen("http://example.com", 'r');
var_dump(stream_get_contents($f));
Resulted in these HTTP requests being sent:
sendto(4, "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\nUser-Agent: dummy\r\n\r\n", 75, MSG_DONTWAIT, NULL, 0) = 75
[…]
sendto(5, "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n", 56, MSG_DONTWAIT, NULL, 0) = 56
But I expected these HTTP requests to be sent:
sendto(4, "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\nUser-Agent: dummy\r\n\r\n", 75, MSG_DONTWAIT, NULL, 0) = 75
[…]
sendto(5, "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\nUser-Agent: dummy\r\n\r\n", 75, MSG_DONTWAIT, NULL, 0) = 75
The user-agent
is missing from the gzopen()
call.
PHP Version
PHP 8.3.13
Operating System
Ubuntu 24.04
mvorisek