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

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

Closed
antiphp opened this issue Dec 22, 2015 · 1 comment
Closed

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

antiphp opened this issue Dec 22, 2015 · 1 comment

Comments

@antiphp
Copy link

antiphp commented Dec 22, 2015

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

samsonasik added a commit to samsonasik/zend-http that referenced this issue May 6, 2018
@samsonasik
Copy link
Contributor

@antiphp I've created PR #149 for it

weierophinney added a commit that referenced this issue Jan 8, 2019
Fixes #36 Client::setUri() should keep relative uri status

Conflicts:
	CHANGELOG.md
weierophinney added a commit that referenced this issue Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants