joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

SocketTransport Location is array

Open brbrbr opened this issue 3 years ago • 0 comments

Steps to reproduce the issue

$http = JHttpFactory::getHttp(new JRegistry,'socket'); $response = $http->get(JURI::root(), [], 1 ); var_dump($response);

//JURI::root() redirects to JURI::root() . '/en/';

Expected result

response of the final destination

Actual result

joomla error utf8_decode(): Argument ($string) must be of type string, array given (JROOT/libraries/vendor/joomla/uri/src/UriHelper.php:42)

SocketTransport::request class itself with $content->headers['Location'] however $content->headers['Location'] is an array.

the new Uri($content->headers['Location']) then fails, using getHeaderLine solves the issue

// Follow Http redirects
        if ($content->code >= 301 && $content->code < 400 && isset($content->headers['Location'])) {
            return $this->request($method, new Uri($content->getHeaderLine('location')), $data, $headers, $timeout, $userAgent);
        }

brbrbr avatar Sep 22 '22 11:09 brbrbr