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

Set user and password in Http class #6886

Closed
wants to merge 4 commits into from
Closed

Set user and password in Http class #6886

wants to merge 4 commits into from

Conversation

SenseException
Copy link

Zend\Uri\Http is extending Zend\Uri\Uri and therefore is also having the getter and setter method for the user info from an URI. Also, the Http class has separate setter and getter for the user and password.

At the moment, when the user info is set, Http automatically is setting the properties for user and password.

$uri = new Http('http://example.com/');
$uri->normalize();
$uri->setUserInfo('user:pass');
$this->assertEquals('user', $uri->getUser());
$this->assertEquals('pass', $uri->getPassword());

But when values are set with setUser and setPassword, the user info is not updated. The following test fails:

$uri = new HttpUri('http://example.com/');
$uri->setUser('user');
$uri->setPassword('pass');
$this->assertEquals('user:pass', $uri->getUserInfo());

It is a strange behaviour that setting the user info is also setting the user and password in Http class, but the setter of user and password doesn't affect the user info value.

I created this pull request with a fix of this behaviour and add some more unittests for Http.

return $this->password;
}

$this->parseUserInfo();
return $this->password;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SenseException

You've got trailing spaces in this line.

@SenseException
Copy link
Author

I found a few more and removed the spaces.

@Ocramius Ocramius self-assigned this Nov 18, 2014
@Ocramius Ocramius added this to the 2.4.0 milestone Nov 18, 2014
@Ocramius Ocramius added the bug label Nov 18, 2014
Ocramius added a commit that referenced this pull request Nov 18, 2014
Ocramius added a commit that referenced this pull request Nov 18, 2014
Ocramius added a commit that referenced this pull request Nov 18, 2014
…lected in internal object state
@Ocramius
Copy link
Member

@SenseException I've manually rebased and merged this PR into develop at 7c7514b. While merging, I found further inconsistencies that make it impossible (in my opinion) to land this PR into the current master because there are very subtle BC breaks due to the broken behavior you reported.

Thanks!

@Ocramius Ocramius closed this Nov 18, 2014
gianarb pushed a commit to zendframework/zend-uri that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-uri that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-uri that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-uri that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-uri that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-uri that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-uri that referenced this pull request May 15, 2015
…or `password` should be reflected in internal object state
gianarb pushed a commit to zendframework/zend-uri that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants