-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace mock with laminas URI implementation
This also centralizes the logic to build path + query. Adding the whole URI to the exception message has been removed, because the string format is always displayed as absolute path, which is confusing.
- Loading branch information
Showing
6 changed files
with
72 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Amp\Http\Client\Internal; | ||
|
||
use Amp\Http\Client\InvalidRequestException; | ||
use Amp\Http\Client\Request; | ||
|
||
/** | ||
* @param Request $request | ||
* | ||
* @return string | ||
* @throws InvalidRequestException | ||
* | ||
* @internal | ||
*/ | ||
function normalizeRequestPathWithQuery(Request $request): string | ||
{ | ||
$path = $request->getUri()->getPath(); | ||
$query = $request->getUri()->getQuery(); | ||
|
||
if ($path === '') { | ||
return '/' . ($query !== '' ? '?' . $query : ''); | ||
} | ||
|
||
if ($path[0] !== '/') { | ||
throw new InvalidRequestException( | ||
$request, | ||
'Relative path (' . $path . ') is not allowed in the request URI' | ||
); | ||
} | ||
|
||
return $path . ($query !== '' ? '?' . $query : ''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters