Request.php : Fix request merge method of data to query

This commit is contained in:
Jérémy Munsch 2022-03-30 12:16:31 +02:00
parent d7b7c15f83
commit bd64c79d5a
No known key found for this signature in database
GPG key ID: 55196BEE445F6049
2 changed files with 17 additions and 1 deletions

View file

@ -2,6 +2,8 @@
### All notable changes to `CRM CLient V2` will be documented in this file.
Fixed : request merge method of data to query (Request.php)
# version 3.0.2
- Regen documentation with php documentor

View file

@ -128,8 +128,22 @@ class Request
{
$this->request = function () {
$uri = $this->uri;
// * If query merge query and data, set data to empty.
if ($this->method->equals(HttpMethods::get())) {
$uri = sprintf("%s?%s", $uri, http_build_query($this->data));
// * Merge query in url with Data
$q = \parse_url($uri, \PHP_URL_QUERY) ?? '';
$q = \strpos($q, '&') !== false ? explode('&', $q) : [];
$query = [];
foreach ($q as $qParam) {
$qParam = explode('=', $qParam, 2);
$query[$qParam[0]] = $qParam[1];
}
// * Remove query part.
$uri = strtok($uri, '?');
// * Append build query
$uri = sprintf("%s?%s", $uri, http_build_query(array_merge($query, $this->data)));
$this->data = [];
}
$request = new Psr7Request(