Skip to content

[WIP] fix issue #37 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

## 1.3.0 - Unreleased

### Added
- Add HttpClientPool client to leverage load balancing and fallback mechanism [see the documentation](http://docs.php-http.org/en/latest/components/client-common.html) for more details

### Changed
- RedirectPlugin: use the full URL instead of the URI to properly keep track of redirects

## 1.2.1 - 2016-07-26

### Changed
Expand Down
12 changes: 6 additions & 6 deletions src/Plugin/RedirectPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public function __construct(array $config = [])
public function handleRequest(RequestInterface $request, callable $next, callable $first)
{
// Check in storage
if (array_key_exists($request->getRequestTarget(), $this->redirectStorage)) {
$uri = $this->redirectStorage[$request->getRequestTarget()]['uri'];
$statusCode = $this->redirectStorage[$request->getRequestTarget()]['status'];
if (array_key_exists((string) $request->getUri(), $this->redirectStorage)) {
$uri = $this->redirectStorage[(string) $request->getUri()]['uri'];
$statusCode = $this->redirectStorage[(string) $request->getUri()]['status'];
$redirectRequest = $this->buildRedirectRequest($request, $uri, $statusCode);

return $first($redirectRequest);
Expand All @@ -157,14 +157,14 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
$this->circularDetection[$chainIdentifier] = [];
}

$this->circularDetection[$chainIdentifier][] = $request->getRequestTarget();
$this->circularDetection[$chainIdentifier][] = (string) $request->getUri();

if (in_array($redirectRequest->getRequestTarget(), $this->circularDetection[$chainIdentifier])) {
if (in_array((string) $redirectRequest->getUri(), $this->circularDetection[$chainIdentifier])) {
throw new CircularRedirectionException('Circular redirection detected', $request, $response);
}

if ($this->redirectCodes[$statusCode]['permanent']) {
$this->redirectStorage[$request->getRequestTarget()] = [
$this->redirectStorage[(string) $request->getUri()] = [
'uri' => $uri,
'status' => $statusCode,
];
Expand Down