Skip to content

Commit a5019ea

Browse files
authored
fix(api): remove remoteAddress from api (#601)
1 parent 23a668e commit a5019ea

File tree

6 files changed

+5
-30
lines changed

6 files changed

+5
-30
lines changed

docs/api.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,7 +2938,6 @@ ResourceType will be one of the following: `document`, `stylesheet`, `image`, `m
29382938
- [response.headers()](#responseheaders)
29392939
- [response.json()](#responsejson)
29402940
- [response.ok()](#responseok)
2941-
- [response.remoteAddress()](#responseremoteaddress)
29422941
- [response.request()](#responserequest)
29432942
- [response.status()](#responsestatus)
29442943
- [response.statusText()](#responsestatustext)
@@ -2965,11 +2964,6 @@ This method will throw if the response body is not parsable via `JSON.parse`.
29652964

29662965
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
29672966

2968-
#### response.remoteAddress()
2969-
- returns: <[Object]>
2970-
- `ip` <[string]> the IP address of the remote server
2971-
- `port` <[number]> the port used to connect to the remote server
2972-
29732967
#### response.request()
29742968
- returns: <[Request]> A matching [Request] object.
29752969

src/chromium/crNetworkManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,11 @@ export class CRNetworkManager {
200200
}
201201

202202
_createResponse(request: InterceptableRequest, responsePayload: Protocol.Network.Response): network.Response {
203-
const remoteAddress: network.RemoteAddress = { ip: responsePayload.remoteIPAddress || '', port: responsePayload.remotePort || 0 };
204203
const getResponseBody = async () => {
205204
const response = await this._client.send('Network.getResponseBody', { requestId: request._requestId });
206205
return platform.Buffer.from(response.body, response.base64Encoded ? 'base64' : 'utf8');
207206
};
208-
return new network.Response(request.request, responsePayload.status, responsePayload.statusText, headersObject(responsePayload.headers), remoteAddress, getResponseBody);
207+
return new network.Response(request.request, responsePayload.status, responsePayload.statusText, headersObject(responsePayload.headers), getResponseBody);
209208
}
210209

211210
_handleRequestRedirect(request: InterceptableRequest, responsePayload: Protocol.Network.Response) {

src/firefox/ffNetworkManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export class FFNetworkManager {
7171
const request = this._requests.get(event.requestId);
7272
if (!request)
7373
return;
74-
const remoteAddress: network.RemoteAddress = { ip: event.remoteIPAddress || '', port: event.remotePort || 0 };
7574
const getResponseBody = async () => {
7675
const response = await this._session.send('Network.getResponseBody', {
7776
requestId: request._id
@@ -83,7 +82,7 @@ export class FFNetworkManager {
8382
const headers: network.Headers = {};
8483
for (const {name, value} of event.headers)
8584
headers[name.toLowerCase()] = value;
86-
const response = new network.Response(request.request, event.status, event.statusText, headers, remoteAddress, getResponseBody);
85+
const response = new network.Response(request.request, event.status, event.statusText, headers, getResponseBody);
8786
this._page._frameManager.requestReceivedResponse(response);
8887
}
8988

src/network.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,32 +218,25 @@ export class Request {
218218
}
219219
}
220220

221-
export type RemoteAddress = {
222-
ip: string,
223-
port: number,
224-
};
225-
226221
type GetResponseBodyCallback = () => Promise<platform.BufferType>;
227222

228223
export class Response {
229224
private _request: Request;
230225
private _contentPromise: Promise<platform.BufferType> | null = null;
231226
_finishedPromise: Promise<Error | null>;
232227
private _finishedPromiseCallback: any;
233-
private _remoteAddress: RemoteAddress;
234228
private _status: number;
235229
private _statusText: string;
236230
private _url: string;
237231
private _headers: Headers;
238232
private _getResponseBodyCallback: GetResponseBodyCallback;
239233

240-
constructor(request: Request, status: number, statusText: string, headers: Headers, remoteAddress: RemoteAddress, getResponseBodyCallback: GetResponseBodyCallback) {
234+
constructor(request: Request, status: number, statusText: string, headers: Headers, getResponseBodyCallback: GetResponseBodyCallback) {
241235
this._request = request;
242236
this._status = status;
243237
this._statusText = statusText;
244238
this._url = request.url();
245239
this._headers = headers;
246-
this._remoteAddress = remoteAddress;
247240
this._getResponseBodyCallback = getResponseBodyCallback;
248241
this._finishedPromise = new Promise(f => {
249242
this._finishedPromiseCallback = f;
@@ -255,10 +248,6 @@ export class Response {
255248
this._finishedPromiseCallback.call(null, error);
256249
}
257250

258-
remoteAddress(): RemoteAddress {
259-
return this._remoteAddress;
260-
}
261-
262251
url(): string {
263252
return this._url;
264253
}

src/webkit/wkInterceptableRequest.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ export class WKInterceptableRequest implements network.RequestDelegate {
109109
}
110110

111111
createResponse(responsePayload: Protocol.Network.Response): network.Response {
112-
const remoteAddress: network.RemoteAddress = { ip: '', port: 0 };
113112
const getResponseBody = async () => {
114113
const response = await this._session.send('Network.getResponseBody', { requestId: this._requestId });
115114
return platform.Buffer.from(response.body, response.base64Encoded ? 'base64' : 'utf8');
116115
};
117-
return new network.Response(this.request, responsePayload.status, responsePayload.statusText, headersObject(responsePayload.headers), remoteAddress, getResponseBody);
116+
return new network.Response(this.request, responsePayload.status, responsePayload.statusText, headersObject(responsePayload.headers), getResponseBody);
118117
}
119118
}
120119

test/network.spec.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT})
217217
expect(requests[0].frame() === page.mainFrame()).toBe(true);
218218
expect(requests[0].frame().url()).toBe(server.EMPTY_PAGE);
219219
});
220-
// FIXME: WebKit doesn't provide remoteIPAddress in the response.
221-
it.skip(WEBKIT)('Page.Events.Response', async({page, server}) => {
220+
it('Page.Events.Response', async({page, server}) => {
222221
const responses = [];
223222
page.on('response', response => responses.push(response));
224223
await page.goto(server.EMPTY_PAGE);
@@ -227,10 +226,6 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT})
227226
expect(responses[0].status()).toBe(200);
228227
expect(responses[0].ok()).toBe(true);
229228
expect(responses[0].request()).toBeTruthy();
230-
const remoteAddress = responses[0].remoteAddress();
231-
// Either IPv6 or IPv4, depending on environment.
232-
expect(remoteAddress.ip.includes('::1') || remoteAddress.ip === '127.0.0.1').toBe(true);
233-
expect(remoteAddress.port).toBe(server.PORT);
234229
});
235230

236231
it.skip(FFOX)('Page.Events.RequestFailed', async({page, server}) => {

0 commit comments

Comments
 (0)