Skip to content

Commit 36c2747

Browse files
committed
- silence the warning if URL is not accessible and/or Content_type is not provided
- provide a correct error message when resource cannot be created
1 parent e9fe30c commit 36c2747

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Client/PhpClient.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public function read(): Response
5959
try {
6060
$resource = $this->createResource(\stream_context_create(['http' => $this->options]));
6161
if ($this->hasError($resource)) {
62-
return $this->getPhpError(HttpStatus::FAILED_DEPENDENCY);
62+
return $this->getPhpError(HttpStatus::FAILED_DEPENDENCY,
63+
'The HTTP client is not created therefore cannot read anything');
6364
}
6465
return new ServerResponse(
6566
\stream_get_contents($resource),
@@ -118,13 +119,16 @@ public function verifySslPeer(bool $value): HttpRequestClient
118119
}
119120

120121
/**
122+
* NOTE: if Content-Type is not provided
123+
* fopen() will assume application/x-www-form-urlencoded
124+
*
121125
* @param resource $context from stream_context_create()
122126
*
123127
* @return resource|bool
124128
*/
125129
protected function createResource($context)
126130
{
127-
return \fopen((string)$this->getUri(), 'rb', false, $context);
131+
return @\fopen((string)$this->getUri(), 'rb', false, $context);
128132
}
129133

130134
protected function prepareRequestBody(): void

0 commit comments

Comments
 (0)