@@ -10,13 +10,11 @@ const {
1010
1111const {
1212 kInspectorRequestId,
13- kContentEncoding,
1413 kResourceType,
1514 getMonotonicTime,
1615 getNextRequestId,
1716 registerDiagnosticChannels,
1817 sniffMimeType,
19- createDecompressor,
2018} = require ( 'internal/inspector/network' ) ;
2119const { Network } = require ( 'inspector' ) ;
2220const EventEmitter = require ( 'events' ) ;
@@ -29,7 +27,6 @@ const convertHeaderObject = (headers = {}) => {
2927 let host ;
3028 let charset ;
3129 let mimeType ;
32- let contentEncoding ;
3330 const dict = { } ;
3431 for ( const { 0 : key , 1 : value } of ObjectEntries ( headers ) ) {
3532 const lowerCasedKey = key . toLowerCase ( ) ;
@@ -41,9 +38,6 @@ const convertHeaderObject = (headers = {}) => {
4138 charset = result . charset ;
4239 mimeType = result . mimeType ;
4340 }
44- if ( lowerCasedKey === 'content-encoding' ) {
45- contentEncoding = typeof value === 'string' ? value . toLowerCase ( ) : undefined ;
46- }
4741 if ( typeof value === 'string' ) {
4842 dict [ key ] = value ;
4943 } else if ( ArrayIsArray ( value ) ) {
@@ -56,7 +50,7 @@ const convertHeaderObject = (headers = {}) => {
5650 dict [ key ] = String ( value ) ;
5751 }
5852 }
59- return [ dict , host , charset , mimeType , contentEncoding ] ;
53+ return [ dict , host , charset , mimeType ] ;
6054} ;
6155
6256/**
@@ -111,10 +105,7 @@ function onClientResponseFinish({ request, response }) {
111105 return ;
112106 }
113107
114- const { 0 : headers , 2 : charset , 3 : mimeType , 4 : contentEncoding } = convertHeaderObject ( response . headers ) ;
115-
116- // Store content encoding on the request for later use
117- request [ kContentEncoding ] = contentEncoding ;
108+ const { 0 : headers , 2 : charset , 3 : mimeType } = convertHeaderObject ( response . headers ) ;
118109
119110 Network . responseReceived ( {
120111 requestId : request [ kInspectorRequestId ] ,
@@ -130,64 +121,24 @@ function onClientResponseFinish({ request, response }) {
130121 } ,
131122 } ) ;
132123
133- // Create a decompressor if the response is compressed
134- const decompressor = createDecompressor ( contentEncoding ) ;
135-
136- if ( decompressor ) {
137- // Pipe decompressed data to DevTools
138- decompressor . on ( 'data' , ( decompressedChunk ) => {
139- Network . dataReceived ( {
140- requestId : request [ kInspectorRequestId ] ,
141- timestamp : getMonotonicTime ( ) ,
142- dataLength : decompressedChunk . byteLength ,
143- encodedDataLength : decompressedChunk . byteLength ,
144- data : decompressedChunk ,
145- } ) ;
146- } ) ;
147-
148- // Handle decompression errors gracefully - fall back to raw data
149- decompressor . on ( 'error' , ( ) => {
150- // If decompression fails, the raw data has already been sent via the fallback
151- } ) ;
152-
153- // Unlike response.on('data', ...), this does not put the stream into flowing mode.
154- EventEmitter . prototype . on . call ( response , 'data' , ( chunk ) => {
155- // Feed the chunk into the decompressor
156- decompressor . write ( chunk ) ;
157- } ) ;
158-
159- // Wait until the response body is consumed by user code.
160- response . once ( 'end' , ( ) => {
161- // End the decompressor stream
162- decompressor . end ( ) ;
163- decompressor . once ( 'end' , ( ) => {
164- Network . loadingFinished ( {
165- requestId : request [ kInspectorRequestId ] ,
166- timestamp : getMonotonicTime ( ) ,
167- } ) ;
168- } ) ;
169- } ) ;
170- } else {
171- // No decompression needed, send data directly
172- // Unlike response.on('data', ...), this does not put the stream into flowing mode.
173- EventEmitter . prototype . on . call ( response , 'data' , ( chunk ) => {
174- Network . dataReceived ( {
175- requestId : request [ kInspectorRequestId ] ,
176- timestamp : getMonotonicTime ( ) ,
177- dataLength : chunk . byteLength ,
178- encodedDataLength : chunk . byteLength ,
179- data : chunk ,
180- } ) ;
124+ // Unlike response.on('data', ...), this does not put the stream into flowing mode.
125+ EventEmitter . prototype . on . call ( response , 'data' , ( chunk ) => {
126+ Network . dataReceived ( {
127+ requestId : request [ kInspectorRequestId ] ,
128+ timestamp : getMonotonicTime ( ) ,
129+ dataLength : chunk . byteLength ,
130+ encodedDataLength : chunk . byteLength ,
131+ data : chunk ,
181132 } ) ;
133+ } ) ;
182134
183- // Wait until the response body is consumed by user code.
184- response . once ( 'end' , ( ) => {
185- Network . loadingFinished ( {
186- requestId : request [ kInspectorRequestId ] ,
187- timestamp : getMonotonicTime ( ) ,
188- } ) ;
135+ // Wait until the response body is consumed by user code.
136+ response . once ( 'end' , ( ) => {
137+ Network . loadingFinished ( {
138+ requestId : request [ kInspectorRequestId ] ,
139+ timestamp : getMonotonicTime ( ) ,
189140 } ) ;
190- }
141+ } ) ;
191142}
192143
193144module . exports = registerDiagnosticChannels ( [
0 commit comments