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

Commit

Permalink
Merge f3ec9aa into 86d5a28
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed Jun 2, 2015
2 parents 86d5a28 + f3ec9aa commit 288da35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 40 deletions.
27 changes: 0 additions & 27 deletions src/ServerRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,6 @@ public static function marshalHeaders(array $server)
return $headers;
}

/**
* Marshal the URI from the $_SERVER array and headers
*
* @param array $server
* @param MessageInterface $request
* @return Uri
* @deprecated as of 0.7.0; use marshalUriFromServer() instead.
*/
public static function marshalUri(array $server, MessageInterface $request)
{
return self::marshalUriFromServer($server, $request->getHeaders());
}

/**
* Marshal the URI from the $_SERVER array and headers
*
Expand Down Expand Up @@ -285,20 +272,6 @@ public static function marshalUriFromServer(array $server, array $headers)
->withQuery($query);
}

/**
* Marshal the host and port from HTTP headers and/or the PHP environment
*
* @param stdClass $accumulator
* @param array $server
* @param MessageInterface $request
* @return array Array with two members, host and port, at indices 0 and 1, respectively
* @deprecated as of 0.7.0; use marshalHostAndPortFromHeaders() instead.
*/
public static function marshalHostAndPort(stdClass $accumulator, array $server, MessageInterface $request)
{
return self::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders());
}

/**
* Marshal the host and port from HTTP headers and/or the PHP environment
*
Expand Down
26 changes: 13 additions & 13 deletions test/ServerRequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testMarshalHostAndPortUsesHostHeaderWhenPresent()
$request = $request->withHeader('Host', 'example.com');

$accumulator = (object) ['host' => '', 'port' => null];
ServerRequestFactory::marshalHostAndPort($accumulator, [], $request);
ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, [], $request->getHeaders());
$this->assertEquals('example.com', $accumulator->host);
$this->assertNull($accumulator->port);
}
Expand All @@ -171,7 +171,7 @@ public function testMarshalHostAndPortWillDetectPortInHostHeaderWhenPresent()
$request = $request->withHeader('Host', 'example.com:8000');

$accumulator = (object) ['host' => '', 'port' => null];
ServerRequestFactory::marshalHostAndPort($accumulator, [], $request);
ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, [], $request->getHeaders());
$this->assertEquals('example.com', $accumulator->host);
$this->assertEquals(8000, $accumulator->port);
}
Expand All @@ -182,7 +182,7 @@ public function testMarshalHostAndPortReturnsEmptyValuesIfNoHostHeaderAndNoServe
$request = $request->withUri(new Uri());

$accumulator = (object) ['host' => '', 'port' => null];
ServerRequestFactory::marshalHostAndPort($accumulator, [], $request);
ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, [], $request->getHeaders());
$this->assertEquals('', $accumulator->host);
$this->assertNull($accumulator->port);
}
Expand All @@ -196,7 +196,7 @@ public function testMarshalHostAndPortReturnsServerNameForHostWhenPresent()
'SERVER_NAME' => 'example.com',
];
$accumulator = (object) ['host' => '', 'port' => null];
ServerRequestFactory::marshalHostAndPort($accumulator, $server, $request);
ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders());
$this->assertEquals('example.com', $accumulator->host);
$this->assertNull($accumulator->port);
}
Expand All @@ -211,7 +211,7 @@ public function testMarshalHostAndPortReturnsServerPortForPortWhenPresentWithSer
'SERVER_PORT' => 8000,
];
$accumulator = (object) ['host' => '', 'port' => null];
ServerRequestFactory::marshalHostAndPort($accumulator, $server, $request);
ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders());
$this->assertEquals('example.com', $accumulator->host);
$this->assertEquals(8000, $accumulator->port);
}
Expand All @@ -226,7 +226,7 @@ public function testMarshalHostAndPortReturnsServerNameForHostIfServerAddrPresen
'SERVER_NAME' => 'example.com',
];
$accumulator = (object) ['host' => '', 'port' => null];
ServerRequestFactory::marshalHostAndPort($accumulator, $server, $request);
ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders());
$this->assertEquals('example.com', $accumulator->host);
}

Expand All @@ -241,7 +241,7 @@ public function testMarshalHostAndPortReturnsServerAddrForHostIfPresentAndHostIs
'SERVER_PORT' => 8000,
];
$accumulator = (object) ['host' => '', 'port' => null];
ServerRequestFactory::marshalHostAndPort($accumulator, $server, $request);
ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders());
$this->assertEquals('[FE80::0202:B3FF:FE1E:8329]', $accumulator->host);
$this->assertEquals(8000, $accumulator->port);
}
Expand All @@ -256,7 +256,7 @@ public function testMarshalHostAndPortWillDetectPortInIpv6StyleHost()
'SERVER_NAME' => '[FE80::0202:B3FF:FE1E:8329:80]',
];
$accumulator = (object) ['host' => '', 'port' => null];
ServerRequestFactory::marshalHostAndPort($accumulator, $server, $request);
ServerRequestFactory::marshalHostAndPortFromHeaders($accumulator, $server, $request->getHeaders());
$this->assertEquals('[FE80::0202:B3FF:FE1E:8329]', $accumulator->host);
$this->assertEquals(80, $accumulator->port);
}
Expand All @@ -271,7 +271,7 @@ public function testMarshalUriDetectsHttpsSchemeFromServerValue()
'HTTPS' => true,
];

$uri = ServerRequestFactory::marshalUri($server, $request);
$uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders());
$this->assertInstanceOf('Zend\Diactoros\Uri', $uri);
$this->assertEquals('https', $uri->getScheme());
}
Expand All @@ -286,7 +286,7 @@ public function testMarshalUriUsesHttpSchemeIfHttpsServerValueEqualsOff()
'HTTPS' => 'off',
];

$uri = ServerRequestFactory::marshalUri($server, $request);
$uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders());
$this->assertInstanceOf('Zend\Diactoros\Uri', $uri);
$this->assertEquals('http', $uri->getScheme());
}
Expand All @@ -300,7 +300,7 @@ public function testMarshalUriDetectsHttpsSchemeFromXForwardedProtoValue()

$server = [];

$uri = ServerRequestFactory::marshalUri($server, $request);
$uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders());
$this->assertInstanceOf('Zend\Diactoros\Uri', $uri);
$this->assertEquals('https', $uri->getScheme());
}
Expand All @@ -315,7 +315,7 @@ public function testMarshalUriStripsQueryStringFromRequestUri()
'REQUEST_URI' => '/foo/bar?foo=bar',
];

$uri = ServerRequestFactory::marshalUri($server, $request);
$uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders());
$this->assertInstanceOf('Zend\Diactoros\Uri', $uri);
$this->assertEquals('/foo/bar', $uri->getPath());
}
Expand All @@ -331,7 +331,7 @@ public function testMarshalUriInjectsQueryStringFromServer()
'QUERY_STRING' => 'bar=baz',
];

$uri = ServerRequestFactory::marshalUri($server, $request);
$uri = ServerRequestFactory::marshalUriFromServer($server, $request->getHeaders());
$this->assertInstanceOf('Zend\Diactoros\Uri', $uri);
$this->assertEquals('bar=baz', $uri->getQuery());
}
Expand Down

0 comments on commit 288da35

Please sign in to comment.