Skip to content

Commit

Permalink
core: set network responseHeadersText from extra info event
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Nov 29, 2023
1 parent 4949ffb commit 4cc901c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions core/lib/network-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ class NetworkRecorder extends RequestEventEmitter {
request.onResponseReceived(data);
}

/**
* @param {{params: LH.Crdp.Network.ResponseReceivedExtraInfoEvent, targetType: LH.Protocol.TargetType, sessionId?: string}} event
*/
onResponseReceivedExtraInfo(event) {
const data = event.params;
const request = this._findRealRequestAndSetSession(
data.requestId, event.targetType, event.sessionId);
if (!request) return;
log.verbose('network', `${request.url} response received extra info`);
request.onResponseReceivedExtraInfo(data);
}

/**
* @param {{params: LH.Crdp.Network.DataReceivedEvent, targetType: LH.Protocol.TargetType, sessionId?: string}} event
*/
Expand Down Expand Up @@ -196,6 +208,7 @@ class NetworkRecorder extends RequestEventEmitter {
case 'Network.requestWillBeSent': return this.onRequestWillBeSent(event);
case 'Network.requestServedFromCache': return this.onRequestServedFromCache(event);
case 'Network.responseReceived': return this.onResponseReceived(event);
case 'Network.responseReceivedExtraInfo': return this.onResponseReceivedExtraInfo(event);
case 'Network.dataReceived': return this.onDataReceived(event);
case 'Network.loadingFinished': return this.onLoadingFinished(event);
case 'Network.loadingFailed': return this.onLoadingFailed(event);
Expand Down
8 changes: 7 additions & 1 deletion core/lib/network-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ class NetworkRequest {
this.frameId = data.frameId;
}

/**
* @param {LH.Crdp.Network.ResponseReceivedExtraInfoEvent} data
*/
onResponseReceivedExtraInfo(data) {
this.responseHeadersText = data.headersText || '';
}

/**
* @param {LH.Crdp.Network.DataReceivedEvent} data
*/
Expand Down Expand Up @@ -354,7 +361,6 @@ class NetworkRequest {
this.timing = response.timing;
if (resourceType) this.resourceType = RESOURCE_TYPES[resourceType];
this.mimeType = response.mimeType;
this.responseHeadersText = response.headersText || '';
this.responseHeaders = NetworkRequest._headersDictToHeadersArray(response.headers);

this.fetchedViaServiceWorker = !!response.fromServiceWorker;
Expand Down

0 comments on commit 4cc901c

Please sign in to comment.