Skip to content

Commit

Permalink
Avoid setting ALPN if not supported
Browse files Browse the repository at this point in the history
Fixes #283.
  • Loading branch information
kelunik committed Dec 13, 2020
1 parent 00c610a commit 1c1f383
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Connection/DefaultConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ public function create(
}

$tlsContext = ($connectContext->getTlsContext() ?? new ClientTlsContext(''))
->withApplicationLayerProtocols($protocols)
->withPeerCapturing();

if ($protocols === ['http/1.1']) {
// If we only have HTTP/1.1 available, don't set application layer protocols.
// There are misbehaving sites like n11.com, see https://github.com/amphp/http-client/issues/255
$tlsContext = $tlsContext->withApplicationLayerProtocols([]);
// If we only have HTTP/1.1 available, don't set application layer protocols.
// There are misbehaving sites like n11.com, see https://github.com/amphp/http-client/issues/255
if ($protocols !== ['http/1.1'] && Socket\hasTlsAlpnSupport()) {
$tlsContext = $tlsContext->withApplicationLayerProtocols($protocols);
}

if ($tlsContext->getPeerName() === '') {
Expand Down

0 comments on commit 1c1f383

Please sign in to comment.