quite interresting, that if you do two file_get_contents
in a row, the 2nd one depends on the 1st one if you use a proxy server.
running the following script:
<?php
$stream_default_opts = array(
'http'=>array(
'proxy'=>"tcp://5.9.78.28:3128",
'request_fulluri' => true,
)
);
stream_context_set_default($stream_default_opts);
file_get_contents("https://www.google.com", false);
file_get_contents("https://getcomposer.org", false);
leads to:
PHP Warning: file_get_contents(https://www.google.com): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
in foo.php on line 21
PHP Warning: file_get_contents(): Peer certificate CN=`getcomposer.org' did not match expected CN=`www.google.com' in foo.php on line 22
PHP Warning: file_get_contents(https://getcomposer.org): failed to open stream: Cannot connect to HTTPS server through proxy in foo.php on line 22
ignore the 404 part, its just the public proxy i used for this demo. i get the error (the peer certificate error) when using my proxy (but not the 404 of course)
- first posted at: https://www.reddit.com/r/PHPhelp/comments/8ai694/file_get_contents_depend_on_previous_calls_when/
- https://stackoverflow.com/a/49717338
- bug reported: https://bugs.php.net/bug.php?id=76196
- cover image by Gratisography https://www.pexels.com/photo/woman-dropped-fail-failure-4091/
Top comments (0)