Skip to content

Commit 05373b7

Browse files
committed
fix: cannot encode full url on send request
1 parent 4cfd9e1 commit 05373b7

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

src/AbstractClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ public function getArrayData(): array
909909
}
910910

911911
/**
912-
* get JSON body as array data
912+
* get JSON body and decode to array data
913913
*
914914
* @return array
915915
*/
@@ -939,11 +939,11 @@ public function getJsonObject(): bool|stdClass
939939
*
940940
* @param object $obj
941941
*
942-
* @return void
942+
* @return object
943943
*/
944-
public function bindBodyTo(object $obj): void
944+
public function bindBodyTo(object $obj): object
945945
{
946-
Obj::init($obj, $this->getArrayData());
946+
return Obj::init($obj, $this->getArrayData());
947947
}
948948

949949
/**

src/ClientInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function trace(string $url, array $params = [], array $headers = [], arra
186186
* Send request to remote URL
187187
*
188188
* @param string $url
189-
* @param array|string|null $data
189+
* @param array|string|null $data Body data or query data.
190190
* @param string $method
191191
* @param array $headers
192192
* @param array $options = AbstractClient::$defaultOptions

src/Curl/CurlClient.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use PhpPkg\Http\Client\Traits\ParseRawResponseTrait;
1919
use Toolkit\Stdlib\Arr\ArrayHelper;
2020
use Toolkit\Stdlib\Helper\Assert;
21-
use Toolkit\Stdlib\Str\UrlHelper;
2221
use function array_merge;
2322
use function curl_close;
2423
use function curl_errno;
@@ -46,7 +45,6 @@
4645
use const CURLAUTH_BASIC;
4746
use const CURLE_COULDNT_CONNECT;
4847
use const CURLE_COULDNT_RESOLVE_HOST;
49-
use const CURLE_HTTP_NOT_FOUND;
5048
use const CURLE_HTTP_POST_ERROR;
5149
use const CURLE_OPERATION_TIMEOUTED;
5250
use const CURLE_READ_ERROR;
@@ -118,7 +116,7 @@ class CurlClient extends AbstractClient implements CurlClientInterface
118116
private static array $canRetryErrorCodes = [
119117
CURLE_COULDNT_RESOLVE_HOST,
120118
CURLE_COULDNT_CONNECT,
121-
CURLE_HTTP_NOT_FOUND,
119+
// CURLE_HTTP_NOT_FOUND,
122120
CURLE_READ_ERROR,
123121
CURLE_OPERATION_TIMEOUTED,
124122
CURLE_HTTP_POST_ERROR,
@@ -402,7 +400,7 @@ protected function prepareRequest(string $url, mixed $data, array $headers, arra
402400
CurlUtil::setMethodToOption($curlOptions, $method);
403401

404402
// set request url
405-
$curlOptions[CURLOPT_URL] = UrlHelper::encode2($url);
403+
$curlOptions[CURLOPT_URL] = $url;
406404

407405
// append http headers
408406
if ($headers = array_merge($this->headers, $options['headers'], $headers)) {

src/FOpenClient.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use PhpPkg\Http\Client\Traits\ParseRawResponseTrait;
1414
use PhpPkg\Http\Client\Traits\StreamContextBuildTrait;
1515
use Throwable;
16-
use Toolkit\Stdlib\Str\UrlHelper;
1716
use function array_merge;
1817
use function fclose;
1918
use function feof;
@@ -101,9 +100,8 @@ public function request(
101100
try {
102101
$ctx = $this->buildStreamContext($url, $headers, $options, $data);
103102

104-
$fullUrl = UrlHelper::encode2($this->fullUrl);
105103
// send request
106-
$this->handle = fopen($fullUrl, 'rb', false, $ctx);
104+
$this->handle = fopen($this->fullUrl, 'rb', false, $ctx);
107105
} catch (Throwable $e) {
108106
throw new ClientException($e->getMessage(), $e->getCode(), $e);
109107
}

src/FileClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use PhpPkg\Http\Client\Traits\ParseRawResponseTrait;
1414
use PhpPkg\Http\Client\Traits\StreamContextBuildTrait;
1515
use Throwable;
16-
use Toolkit\Stdlib\Str\UrlHelper;
1716
use function array_merge;
1817
use function file_get_contents;
1918
use function function_exists;
@@ -70,7 +69,7 @@ public function request(
7069

7170
try {
7271
$reqCtx = $this->buildStreamContext($url, $headers, $options, $data);
73-
$fullUrl = UrlHelper::encode2($this->fullUrl);
72+
$fullUrl = $this->fullUrl;
7473

7574
// send request
7675
$this->responseBody = file_get_contents($fullUrl, false, $reqCtx);

0 commit comments

Comments
 (0)