* Set a default ssl.peer_name context in StreamHandler
This is required when using the `force_ip_resolve` option with the stream
handler:
As that option will cause the StreamHandler to manually resolve the hostname
and then replace the hostname with the resolved IP address in the URI, PHP
will use that IP address by default in the SNI of the TLS handshake.
Set an explicit ssl.peer_name within the stream's context based on the hostname
in the URL to fix this.
Setting a proper SNI is independent from TLS certificate validation, thus this
value must not be dependent on the `verify` option.
A test cannot be added, due to a lack of TLS support with the current testing
infrastructure. TLS support cannot easily be added, because it would require a
separate port and also certificates that would need to be commited to the
repository. However correctness can be verified by setting `force_ip_resolve`
to `v4` and attempting to make a request to `https://www.example.com/`. It will
fail without this commit and work with.
* Add tests/Handler/Network/StreamHandlerTest.php
* Handle non-HTTP schemes gracefully in StreamHandler
If an URI that does not use the HTTP stream wrapper is passed to the
StreamHandler then the magic `$http_response_header` variable will not be
filled, thus remaining `null`.
This ultimately results in a `TypeError`, because `null` is passed to
HeaderProcessor::parseHeaders(), which expects an `array`.
* Reject non-HTTP schemes in StreamHandler
Non-HTTP schemes are effectively not supported, because the HTTP response
headers will only be filled for the `http` and `https` stream wrappers. Also
Guzzle is an HTTP client after all.
Reject non-HTTP schemes early on to improve error messages and to prevent
possible exploits using odd stream wrappers in case an non-fully-trusted URL is
passed to Guzzle.
* Throw `InvalidArgumentException` when an incorrect `headers` array is provided
As discussed in PR #2916 after it was merged an `InvalidArgumentException` is
more fitting, as passing an invalid `headers` array is a clear programming
error that needs to be fixed and not caught.
This is consistent with the validation of the other options, e.g. when using
`multipart` and `form_params` at the same time.
see #2916
see a2b8dd1ad7e733d50e9c7b80cb375e0883a7088d
* Remove obsolete import in Client.php / ClientTest.php