Skip to content
This repository was archived by the owner on Apr 27, 2021. It is now read-only.

Commit bed1aa7

Browse files
committed
Add target on log for proxies, even if not coming for redirectionio agent
1 parent b3aacd1 commit bed1aa7

File tree

3 files changed

+15
-29
lines changed

3 files changed

+15
-29
lines changed

src/Client.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,17 @@ public function findRedirect(Request $request)
7878
}
7979

8080
$ruleId = null;
81+
$location = null;
82+
8183
if (isset($json['matched_rule'], $json['matched_rule']['id'])) {
8284
$ruleId = $json['matched_rule']['id'];
8385
}
8486

85-
if (410 === $json['status_code']) {
86-
return new Response(410, $ruleId);
87+
if (isset($json['location'])) {
88+
$location = $json['location'];
8789
}
8890

89-
return new RedirectResponse($json['location'], (int) $json['status_code'], $ruleId);
91+
return new Response((int) $json['status_code'], $ruleId, $location);
9092
}
9193

9294
public function log(Request $request, Response $response)
@@ -101,7 +103,7 @@ public function log(Request $request, Response $response)
101103
'use_json' => true,
102104
];
103105

104-
if ($response instanceof RedirectResponse) {
106+
if ($response->getLocation()) {
105107
$responseContext['target'] = $response->getLocation();
106108
}
107109

src/HttpMessage/RedirectResponse.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/HttpMessage/Response.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ class Response
66
{
77
private $statusCode;
88
private $ruleId;
9+
private $location;
910

1011
/**
1112
* @param int $statusCode
1213
* @param string $ruleId
14+
* @param string $location
1315
*/
14-
public function __construct($statusCode = 200, $ruleId = null)
16+
public function __construct($statusCode = 200, $ruleId = null, $location = null)
1517
{
1618
$this->statusCode = $statusCode;
1719
$this->ruleId = $ruleId;
20+
$this->location = $location;
1821
}
1922

2023
public function getStatusCode()
@@ -26,4 +29,9 @@ public function getRuleId()
2629
{
2730
return $this->ruleId;
2831
}
32+
33+
public function getLocation()
34+
{
35+
return $this->location;
36+
}
2937
}

0 commit comments

Comments
 (0)