Skip to content

Commit 89a398c

Browse files
committed
fix: fixed TypeError: stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given
1 parent 0b4de01 commit 89a398c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Yii Framework 2 HTTP client extension Change Log
44
2.0.17 under development
55
------------------------
66

7-
- no changes in this release.
7+
- Bug: Fixed TypeError: stream_get_contents(): Argument #1 ($stream) must be of type resource, bool given (shaperman)
88

99

1010
2.0.16 February 13, 2025

src/StreamTransport.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public function send($request)
5959
try {
6060
$context = stream_context_create($contextOptions);
6161
$stream = fopen($url, 'rb', false, $context);
62+
if (false === $stream) {
63+
$error = error_get_last();
64+
throw new Exception($error['message']);
65+
}
6266
$responseContent = stream_get_contents($stream);
6367
// see https://php.net/manual/en/reserved.variables.httpresponseheader.php
6468
$responseHeaders = (array)$http_response_header;

0 commit comments

Comments
 (0)