@@ -193,6 +193,21 @@ export abstract class HttpResponseBase {
193193 */
194194 readonly redirected ?: boolean ;
195195
196+ /**
197+ * Indicates the type of the HTTP response, based on how the request was made and how the browser handles the response.
198+ *
199+ * This corresponds to the `type` property of the Fetch API's `Response` object, which can indicate values such as:
200+ * - `'basic'`: A same-origin response, allowing full access to the body and headers.
201+ * - `'cors'`: A cross-origin response with CORS enabled, exposing only safe response headers.
202+ * - `'opaque'`: A cross-origin response made with `no-cors`, where the response body and headers are inaccessible.
203+ * - `'opaqueredirect'`: A response resulting from a redirect followed in `no-cors` mode.
204+ * - `'error'`: A response representing a network error or similar failure.
205+ *
206+ * This property is only available when using the Fetch-based backend (via `withFetch()`).
207+ * When using Angular's (XHR) backend, this value will be `undefined`.
208+ */
209+ readonly responseType ?: ResponseType ;
210+
196211 /**
197212 * Super-constructor for all responses.
198213 *
@@ -206,6 +221,7 @@ export abstract class HttpResponseBase {
206221 statusText ?: string ;
207222 url ?: string ;
208223 redirected ?: boolean ;
224+ responseType ?: ResponseType ;
209225 } ,
210226 defaultStatus : number = 200 ,
211227 defaultStatusText : string = 'OK' ,
@@ -217,7 +233,7 @@ export abstract class HttpResponseBase {
217233 this . statusText = init . statusText || defaultStatusText ;
218234 this . url = init . url || null ;
219235 this . redirected = init . redirected ;
220-
236+ this . responseType = init . responseType ;
221237 // Cache the ok value to avoid defining a getter.
222238 this . ok = this . status >= 200 && this . status < 300 ;
223239 }
@@ -298,6 +314,7 @@ export class HttpResponse<T> extends HttpResponseBase {
298314 statusText ?: string ;
299315 url ?: string ;
300316 redirected ?: boolean ;
317+ responseType ?: ResponseType ;
301318 } = { } ,
302319 ) {
303320 super ( init ) ;
@@ -313,6 +330,7 @@ export class HttpResponse<T> extends HttpResponseBase {
313330 statusText ?: string ;
314331 url ?: string ;
315332 redirected ?: boolean ;
333+ responseType ?: ResponseType ;
316334 } ) : HttpResponse < T > ;
317335 clone < V > ( update : {
318336 body ?: V | null ;
@@ -321,6 +339,7 @@ export class HttpResponse<T> extends HttpResponseBase {
321339 statusText ?: string ;
322340 url ?: string ;
323341 redirected ?: boolean ;
342+ responseType ?: ResponseType ;
324343 } ) : HttpResponse < V > ;
325344 clone (
326345 update : {
@@ -330,6 +349,7 @@ export class HttpResponse<T> extends HttpResponseBase {
330349 statusText ?: string ;
331350 url ?: string ;
332351 redirected ?: boolean ;
352+ responseType ?: ResponseType ;
333353 } = { } ,
334354 ) : HttpResponse < any > {
335355 return new HttpResponse < any > ( {
@@ -339,6 +359,7 @@ export class HttpResponse<T> extends HttpResponseBase {
339359 statusText : update . statusText || this . statusText ,
340360 url : update . url || this . url || undefined ,
341361 redirected : update . redirected ?? this . redirected ,
362+ responseType : update . responseType ?? this . responseType ,
342363 } ) ;
343364 }
344365}
@@ -373,6 +394,7 @@ export class HttpErrorResponse extends HttpResponseBase implements Error {
373394 statusText ?: string ;
374395 url ?: string ;
375396 redirected ?: boolean ;
397+ responseType ?: ResponseType ;
376398 } ) {
377399 // Initialize with a default status of 0 / Unknown Error.
378400 super ( init , 0 , 'Unknown Error' ) ;
0 commit comments