The HTTP context's proxy option belongs to PHP's HTTP stream wrapper. A raw TCP connection created by stream_socket_client does not become an HTTP proxy client because that option exists in a context object.

If the code connects directly to the destination address, it is opening that TCP route. If it connects to the proxy address instead, the next bytes still need to implement the proxy protocol.

For HTTP CONNECT, that means a valid destination host and port, any required proxy authentication, complete response parsing, and acceptance before the destination protocol begins. A single fread call searching for a success phrase is not a complete connector. TCP can split a reply across reads or return additional bytes that must be preserved.

For an HTTPS destination, TLS then needs to start through the established tunnel and verify the destination identity. The proxy hostname is not the website's certificate identity.

Use a client or connector with documented support for the required proxy protocol when the task is simply to fetch a URL. PHP cURL's HTTP and SOCKS settings provide one supported URL-fetch path. A raw stream is useful when the application owns that lower-level protocol work; it should not silently inherit assumptions from an unrelated HTTP-wrapper example.

Аффингæй хæстæг статьялтæ