Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

setUri() invalidates relative URI when setting default ports #36

Closed
@antiphp

Description

@antiphp

Hi,

when setting a relative URI /example the Zend\Http\Client::setUri() method adds a default port and so invalidates the URI resulting in isValidRelative() returning FALSE instead of TRUE.

<?php
require './vendor/autoload.php';
$relativeUri = '/example';
$client = new Zend\Http\Client($relativeUri);
$uri = new Zend\Uri\Http($relativeUri);
var_dump($client->getUri()->isValidRelative(), $uri->isValidRelative());

Expected output

boolean(true)
boolean(true)

Actual output

boolean(false)
boolean(true)

I don't know how to build a patch, but line 323 of Client.php should be
if (! $this->getUri()->getPort() && $this->getUri()->isAbsolute()) {
instead of
if (! $this->getUri()->getPort()) {

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions