Permalink
Browse files

[#4215] CS fixes

- per php-cs-fixer
  • Loading branch information...
weierophinney committed Apr 22, 2013
1 parent e0b243d commit 9d50a297d02506fd4aaa444705e9d65f76aed0e8
Showing with 29 additions and 29 deletions.
  1. +7 −7 library/Zend/Http/Client.php
  2. +22 −22 tests/ZendTest/Http/ClientTest.php
@@ -301,15 +301,15 @@ public function setUri($uri)
// remember host of last request
$lastHost = $this->getRequest()->getUri()->getHost();
$this->getRequest()->setUri($uri);
-
+
// if host changed, the HTTP authentication should be cleared for security
- // reasons, see #4215 for a discussion - currently authentication is also
+ // reasons, see #4215 for a discussion - currently authentication is also
// cleared for peer subdomains due to technical limits
$nextHost = $this->getRequest()->getUri()->getHost();
if (!preg_match('/' . preg_quote($lastHost, '/') . '$/i', $nextHost)) {
$this->clearAuth();
}
-
+
// Set auth if username and password has been specified in the uri
if ($this->getUri()->getUser() && $this->getUri()->getPassword()) {
$this->setAuth($this->getUri()->getUser(), $this->getUri()->getPassword());
@@ -477,7 +477,7 @@ public function resetParameters($clearCookies = false, $clearAuth = true)
if ($clearCookies) {
$this->clearCookies();
}
-
+
if ($clearAuth) {
$this->clearAuth();
}
@@ -924,7 +924,7 @@ public function send(Request $request = null)
$this->resetParameters(false, false);
$this->setMethod(Request::METHOD_GET);
}
-
+
// If we got a well formed absolute URI
if (($scheme = substr($location, 0, 6)) &&
@@ -970,12 +970,12 @@ public function send(Request $request = null)
*
* @return Client
*/
- public function reset()
+ public function reset()
{
$this->resetParameters();
$this->clearAuth();
$this->clearCookies();
-
+
return $this;
}
@@ -199,7 +199,7 @@ public function testEncodeAuthHeaderThrowsExceptionWhenInvalidAuthTypeIsUsed()
{
$encoded = Client::encodeAuthHeader('test', 'test', 'test');
}
-
+
public function testIfMaxredirectWorksCorrectly()
{
$testAdapter = new Test();
@@ -220,29 +220,29 @@ public function testIfMaxredirectWorksCorrectly()
"HTTP/1.1 303 See Other\r\n\r\n"
. "Page #3"
);
-
+
// create a client which allows one redirect at most!
$client = new Client('http://www.example.org/part1', array(
'adapter' => $testAdapter,
'maxredirects' => 1,
'storeresponse' => true
));
-
+
// do the request
$response = $client->setMethod('GET')->send();
-
+
// response should be the second response, since third response should not
// be requested, due to the maxredirects = 1 limit
$this->assertEquals($response->getContent(), "Page #2");
}
-
+
public function testIfClientDoesNotLooseAuthenticationOnRedirect()
{
// set up user credentials
$user = 'username123';
$password = 'password456';
$encoded = Client::encodeAuthHeader($user, $password, Client::AUTH_BASIC);
-
+
// set up two responses that simulate a redirection
$testAdapter = new Test();
$testAdapter->setResponse(
@@ -254,31 +254,31 @@ public function testIfClientDoesNotLooseAuthenticationOnRedirect()
"HTTP/1.1 200 OK\r\n\r\n"
. "Welcome to this Website."
);
-
+
// create client with HTTP basic authentication
$client = new Client('http://www.example.org/part1', array(
'adapter' => $testAdapter,
'maxredirects' => 1
));
$client->setAuth($user, $password, Client::AUTH_BASIC);
-
+
// do request
$response = $client->setMethod('GET')->send();
-
+
// the last request should contain the Authorization header
$this->assertTrue(strpos($client->getLastRawRequest(), $encoded) !== false);
}
-
+
public function testIfClientDoesNotForwardAuthenticationToForeignHost()
{
// set up user credentials
$user = 'username123';
$password = 'password456';
$encoded = Client::encodeAuthHeader($user, $password, Client::AUTH_BASIC);
-
+
$testAdapter = new Test();
$client = new Client(null, array('adapter' => $testAdapter));
-
+
// set up two responses that simulate a redirection from example.org to example.com
$testAdapter->setResponse(
"HTTP/1.1 303 See Other\r\n"
@@ -289,16 +289,16 @@ public function testIfClientDoesNotForwardAuthenticationToForeignHost()
"HTTP/1.1 200 OK\r\n\r\n"
. "Welcome to this Website."
);
-
+
// set auth and do request
$client->setUri('http://example.org/part1')
->setAuth($user, $password, Client::AUTH_BASIC);
$response = $client->setMethod('GET')->send();
-
+
// the last request should NOT contain the Authorization header,
// because example.com is different from example.org
$this->assertTrue(strpos($client->getLastRawRequest(), $encoded) === false);
-
+
// set up two responses that simulate a rediration from example.org to sub.example.org
$testAdapter->setResponse(
"HTTP/1.1 303 See Other\r\n"
@@ -309,16 +309,16 @@ public function testIfClientDoesNotForwardAuthenticationToForeignHost()
"HTTP/1.1 200 OK\r\n\r\n"
. "Welcome to this Website."
);
-
+
// set auth and do request
$client->setUri('http://example.org/part1')
->setAuth($user, $password, Client::AUTH_BASIC);
$response = $client->setMethod('GET')->send();
-
- // the last request should contain the Authorization header,
+
+ // the last request should contain the Authorization header,
// because sub.example.org is a subdomain unter example.org
$this->assertFalse(strpos($client->getLastRawRequest(), $encoded) === false);
-
+
// set up two responses that simulate a rediration from sub.example.org to example.org
$testAdapter->setResponse(
"HTTP/1.1 303 See Other\r\n"
@@ -329,13 +329,13 @@ public function testIfClientDoesNotForwardAuthenticationToForeignHost()
"HTTP/1.1 200 OK\r\n\r\n"
. "Welcome to this Website."
);
-
+
// set auth and do request
$client->setUri('http://sub.example.org/part1')
->setAuth($user, $password, Client::AUTH_BASIC);
$response = $client->setMethod('GET')->send();
-
- // the last request should NOT contain the Authorization header,
+
+ // the last request should NOT contain the Authorization header,
// because example.org is not a subdomain unter sub.example.org
$this->assertTrue(strpos($client->getLastRawRequest(), $encoded) === false);
}

0 comments on commit 9d50a29

Please sign in to comment.