Skip to content

Commit 2e4e11f

Browse files
authored
Merge branch 'master' into feature/exception-only-on-5XX
2 parents 239962b + 6dee34d commit 2e4e11f

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Change Log
22

3-
## Upcoming
3+
## 1.8 (unreleased)
44

55
### Added
66

77
- Add an option on ErrorPlugin to only throw exception on response with 5XX status code.
88

9+
### Changed
10+
11+
- AddPathPlugin no longer add prefix multiple times if a request is restarted - it now only adds the prefix if that request chain has not yet passed through the AddPathPlugin
12+
913
## 1.7.0 - 2017-11-30
1014

1115
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"extra": {
3939
"branch-alias": {
40-
"dev-master": "1.7-dev"
40+
"dev-master": "1.8-dev"
4141
}
4242
}
4343
}

src/Plugin/AddPathPlugin.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ final class AddPathPlugin implements Plugin
1818
*/
1919
private $uri;
2020

21+
/**
22+
* Stores identifiers of the already altered requests.
23+
*
24+
* @var array
25+
*/
26+
private $alteredRequests = [];
27+
2128
/**
2229
* @param UriInterface $uri
2330
*/
@@ -39,9 +46,14 @@ public function __construct(UriInterface $uri)
3946
*/
4047
public function handleRequest(RequestInterface $request, callable $next, callable $first)
4148
{
42-
$request = $request->withUri($request->getUri()
43-
->withPath($this->uri->getPath().$request->getUri()->getPath())
44-
);
49+
$identifier = spl_object_hash((object) $first);
50+
51+
if (!array_key_exists($identifier, $this->alteredRequests)) {
52+
$request = $request->withUri($request->getUri()
53+
->withPath($this->uri->getPath().$request->getUri()->getPath())
54+
);
55+
$this->alteredRequests[$identifier] = $identifier;
56+
}
4557

4658
return $next($request);
4759
}

0 commit comments

Comments
 (0)