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

Commit e990506

Browse files
committed
Add target on log for proxies, even if not coming for redirectionio agent
1 parent 5bc7e08 commit e990506

File tree

5 files changed

+622
-678
lines changed

5 files changed

+622
-678
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"babel-runtime": "^6.26.0"
3838
},
3939
"devDependencies": {
40+
"@redirectionio/proxy": "file:./.",
4041
"babel-cli": "^6.26.0",
4142
"babel-eslint": "^8.2.1",
4243
"babel-plugin-transform-runtime": "^6.23.0",
@@ -45,7 +46,6 @@
4546
"eslint": "^4.14.0",
4647
"express": "^4.16.2",
4748
"jest": "^22.0.4",
48-
"pm2": "^2.9.3",
49-
"@redirectionio/proxy": "file:./"
49+
"pm2": "^2.9.3"
5050
}
5151
}

src/Client.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import AgentNotFoundError from './Error/AgentNotFoundError'
44
import BadConfigurationError from './Error/BadConfigurationError'
55
import ConnectionNotWorkingError from './Error/ConnectionNotWorkingError'
66
import NullLogger from './Logger/NullLogger'
7-
import RedirectResponse from './HttpMessage/RedirectResponse'
87
import Response from './HttpMessage/Response'
98

109
export default class Client {
@@ -85,11 +84,7 @@ export default class Client {
8584
ruleId = response.matched_rule.id
8685
}
8786

88-
if (410 === response.status_code) {
89-
return new Response(410, ruleId)
90-
}
91-
92-
return new RedirectResponse(response.location, Number(response.status_code), ruleId)
87+
return new Response(Number(response.status_code), ruleId, response.location)
9388
}
9489

9590
/**
@@ -107,7 +102,7 @@ export default class Client {
107102
'use_json': true,
108103
}
109104

110-
if (response instanceof RedirectResponse) {
105+
if (response.location) {
111106
context.target = response.location
112107
}
113108

src/HttpMessage/RedirectResponse.js

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

src/HttpMessage/Response.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default class Response {
2-
constructor(statusCode = 200, ruleId = null) {
2+
constructor(statusCode = 200, ruleId = null, location = null) {
33
this.statusCode = statusCode
44
this.ruleId = ruleId
5+
this.location = location
56
}
67
}

0 commit comments

Comments
 (0)