@@ -64,6 +64,8 @@ export function initializeFetchInterceptor() {
6464 // Capture response metadata immediately
6565 const responseClone = response . clone ( ) ;
6666 responseStatus = response . status ;
67+ const responseStatusText =
68+ response . statusText || getStatusText ( response . status ) ;
6769 responseHeaders = serializeHeaders ( response . headers ) ;
6870 const duration = Math . round ( performance . now ( ) - startTime ) ;
6971
@@ -79,6 +81,7 @@ export function initializeFetchInterceptor() {
7981 ) ,
8082 requestBody,
8183 status : responseStatus ,
84+ statusText : responseStatusText ,
8285 responseHeaders,
8386 responseBody : body ,
8487 duration,
@@ -94,6 +97,7 @@ export function initializeFetchInterceptor() {
9497 ) ,
9598 requestBody,
9699 status : responseStatus ,
100+ statusText : responseStatusText ,
97101 responseHeaders,
98102 responseBody : `[Error reading body: ${ error . message } ]` ,
99103 duration,
@@ -112,6 +116,7 @@ export function initializeFetchInterceptor() {
112116 requestHeaders : serializeHeaders ( requestDetails . headers ) ,
113117 requestBody,
114118 status : 0 ,
119+ statusText : '' ,
115120 responseHeaders : { } ,
116121 responseBody : `[Network error: ${ error . message } ]` ,
117122 duration,
@@ -311,3 +316,58 @@ function serializeHeaders( headers ) {
311316
312317 return result ;
313318}
319+
320+ /**
321+ * Maps HTTP status codes to their standard status text.
322+ * Used as fallback when response.statusText is empty (common with HTTP/2).
323+ *
324+ * @param {number } status The HTTP status code.
325+ *
326+ * @return {string } The corresponding status text, or empty string if unknown.
327+ */
328+ function getStatusText ( status ) {
329+ const statusTexts = {
330+ // 1xx Informational
331+ 100 : 'Continue' ,
332+ 101 : 'Switching Protocols' ,
333+ // 2xx Success
334+ 200 : 'OK' ,
335+ 201 : 'Created' ,
336+ 202 : 'Accepted' ,
337+ 203 : 'Non-Authoritative Information' ,
338+ 204 : 'No Content' ,
339+ 205 : 'Reset Content' ,
340+ 206 : 'Partial Content' ,
341+ // 3xx Redirection
342+ 300 : 'Multiple Choices' ,
343+ 301 : 'Moved Permanently' ,
344+ 302 : 'Found' ,
345+ 303 : 'See Other' ,
346+ 304 : 'Not Modified' ,
347+ 307 : 'Temporary Redirect' ,
348+ 308 : 'Permanent Redirect' ,
349+ // 4xx Client Error
350+ 400 : 'Bad Request' ,
351+ 401 : 'Unauthorized' ,
352+ 403 : 'Forbidden' ,
353+ 404 : 'Not Found' ,
354+ 405 : 'Method Not Allowed' ,
355+ 406 : 'Not Acceptable' ,
356+ 408 : 'Request Timeout' ,
357+ 409 : 'Conflict' ,
358+ 410 : 'Gone' ,
359+ 413 : 'Payload Too Large' ,
360+ 414 : 'URI Too Long' ,
361+ 415 : 'Unsupported Media Type' ,
362+ 422 : 'Unprocessable Entity' ,
363+ 429 : 'Too Many Requests' ,
364+ // 5xx Server Error
365+ 500 : 'Internal Server Error' ,
366+ 501 : 'Not Implemented' ,
367+ 502 : 'Bad Gateway' ,
368+ 503 : 'Service Unavailable' ,
369+ 504 : 'Gateway Timeout' ,
370+ } ;
371+
372+ return statusTexts [ status ] || '' ;
373+ }
0 commit comments