smsapi / smsapi-php-client

SMSAPI PHP client that allows you to send messages, manage Short URLs and administrate your SMSAPI account.
https://www.smsapi.pl
Other
64 stars 39 forks source link

Make prepareRequestHttpClient() is cutting port number from uri passed in smsapiPlServiceWithUri() #131

Closed domino316 closed 6 months ago

domino316 commented 7 months ago

Hi,

I was trying to pass uri in smsapiPlServiceWithUri() method, and my uri contained port number. I saw that the messages was sent with default port 80. After some digging I saw that prepareRequestHttpClient is just not picking it from uri.

I have already figured it out and this is really small change. Or perhaps this is not possible due to backward compatibility or some security related stuff?

domino316 commented 7 months ago

I suggest changes in files:

"smsapi/php-client/src/Curl/HttpClient.php"

private function prepareRequestHttpClient(RequestInterface $request)
{
    $port = $request->getUri()->getPort() ? ':' . (string) $request->getUri()->getPort() : '';
    $url = sprintf("%s://%s%s%s", $request->getUri()->getScheme(), $request->getUri()->getHost(), $port, $request->getRequestTarget());

"smsapi/php-client/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php"

prependBaseUri()

    $host = $baseUriParts['host'] ?? '';
    $port = $baseUriParts['port'] ?? '';
    $basePath = $baseUriParts['path'] ?? '';
    $basePath = rtrim($basePath, '/');

    $uri = $uri->withPath($basePath . '/' . $uri->getPath());
    $uri = $uri->withHost($host);
    $uri = $uri->withScheme($scheme);
    $uri = $uri->withPort($port);
mpawikowski commented 7 months ago

Hello,

I forwarded your requst to our IT department.

maciejlew commented 6 months ago

Released: https://github.com/smsapi/smsapi-php-client/releases/tag/v3.0.11