HttpResponse & Events
HttpResponse<TBody>
Represents a completed HTTP response, available when observing with HttpObserveType.Response or via .getResponse().
class HttpResponse<TBody = any> {
readonly headers: Headers;
readonly ok: boolean;
readonly status: number;
readonly statusText: string;
readonly url: string | null;
readonly body: TBody;
readonly contentType: string;
readonly hasBody: boolean;
}
| Property | Description |
|---|---|
headers | Response headers |
ok | true when status is 200–299 |
status | HTTP status code |
statusText | HTTP status message |
url | Final URL after redirects |
body | Parsed response body |
contentType | Content-Type header value without encoding suffix |
hasBody | true if a non-null body was received |
clone(update?) — returns a shallow copy with optional overrides.
HttpEventType enum
enum HttpEventType {
Sent = 'Sent',
UploadProgress = 'UploadProgress',
ResponseHeader = 'ResponseHeader',
DownloadProgress = 'DownloadProgress',
Response = 'Response',
User = 'User',
}
Event interfaces
When observing with HttpObserveType.Events, the observable emits a sequence of HttpEvent items in this order:
HttpSentEvent
Emitted immediately after the request is dispatched over the wire.
interface HttpSentEvent {
type: HttpEventType.Sent;
request: Request;
}
HttpUploadProgressEvent
Emitted during request body upload. Only emitted when reportProgress: true is set.
interface HttpUploadProgressEvent {
type: HttpEventType.UploadProgress;
request: Request;
loaded: number;
total?: number;
}
HttpResponseHeaderEvent
Emitted as soon as response status and headers arrive, before the body is read.
interface HttpResponseHeaderEvent {
type: HttpEventType.ResponseHeader;
request: Request;
response: HttpResponse<never>;
}
HttpDownloadProgressEvent
Emitted while the response body is streaming. Only emitted when reportProgress: true.
interface HttpDownloadProgressEvent {
type: HttpEventType.DownloadProgress;
request: Request;
loaded: number;
total?: number;
}
HttpResponseEvent<T>
Emitted once the full response (headers + body) is available. This is the last event.
interface HttpResponseEvent<T = any> {
type: HttpEventType.Response;
request: Request;
response: HttpResponse<T>;
}
HttpUserEvent
Custom event emitted by interceptors or custom backends.
interface HttpUserEvent {
type: HttpEventType.User;
request: Request;
[key: string]: any;
}
HttpEvent<T> union type
type HttpEvent<T = any, TResponseExt = {}> =
| HttpSentEvent
| HttpUploadProgressEvent
| HttpResponseHeaderEvent
| HttpDownloadProgressEvent
| HttpResponseEvent<T, TResponseExt>
| HttpUserEvent;