diff --git a/CHANGELOG.md b/CHANGELOG.md index 0909b69..b8d7ec5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 2.1.2 + + * add `stream_flags` option + ## 2.1.1 * Fixed constructor to work nicely with version 1 style arguments (e.g. HttplugBundle) diff --git a/src/Client.php b/src/Client.php index 6f57816..17dd7bd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -108,7 +108,7 @@ protected function createSocket(RequestInterface $request, string $remote, bool { $errNo = null; $errMsg = null; - $socket = @stream_socket_client($remote, $errNo, $errMsg, floor($this->config['timeout'] / 1000), STREAM_CLIENT_CONNECT, $this->config['stream_context']); + $socket = @stream_socket_client($remote, $errNo, $errMsg, floor($this->config['timeout'] / 1000), STREAM_CLIENT_CONNECT | $this->config['stream_flags'], $this->config['stream_context']); if (false === $socket) { if (110 === $errNo) { @@ -142,9 +142,9 @@ protected function closeSocket($socket) /** * Return configuration for the socket client. * - * @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array, stream_context_param?: array, ssl?: ?boolean, write_buffer_size?: int, ssl_method?: int} $config + * @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array, stream_context_param?: array, stream_flags: ?int, ssl?: ?boolean, write_buffer_size?: int, ssl_method?: int} $config * - * @return array{remote_socket: string|null, timeout: int, stream_context: resource, stream_context_options: array, stream_context_param: array, ssl: ?boolean, write_buffer_size: int, ssl_method: int} + * @return array{remote_socket: string|null, timeout: int, stream_context: resource, stream_context_options: array, stream_context_param: array, stream_flags: ?int, ssl: ?boolean, write_buffer_size: int, ssl_method: int} */ protected function configure(array $config = []) { @@ -154,6 +154,7 @@ protected function configure(array $config = []) 'timeout' => null, 'stream_context_options' => [], 'stream_context_param' => [], + 'stream_flags' => 0, 'ssl' => null, 'write_buffer_size' => 8192, 'ssl_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, @@ -165,6 +166,7 @@ protected function configure(array $config = []) $resolver->setAllowedTypes('stream_context_options', 'array'); $resolver->setAllowedTypes('stream_context_param', 'array'); + $resolver->setAllowedTypes('stream_flags', 'int'); $resolver->setAllowedTypes('stream_context', 'resource'); $resolver->setAllowedTypes('ssl', ['bool', 'null']);