feat: deprecate @angular/http in favor of @angular/common/http (#18906)
As of 5.0, @angular/http is deprecated. @angular/common/http will be the official HTTP API in Angular going forward. PR Close #18906
This commit is contained in:

committed by
Miško Hevery

parent
1ef558b57c
commit
72c7b6edea
@ -20,7 +20,7 @@ import {HttpEvent} from './response';
|
||||
*
|
||||
* In an `HttpInterceptor`, the `HttpHandler` parameter is the next interceptor in the chain.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export abstract class HttpHandler {
|
||||
abstract handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
|
||||
@ -34,7 +34,7 @@ export abstract class HttpHandler {
|
||||
* When injected, `HttpBackend` dispatches requests directly to the backend, without going
|
||||
* through the interceptor chain.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export abstract class HttpBackend implements HttpHandler {
|
||||
abstract handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
|
||||
|
@ -46,7 +46,7 @@ function addBody<T>(
|
||||
}
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export type HttpObserve = 'body' | 'events' | 'response';
|
||||
|
||||
@ -57,7 +57,7 @@ export type HttpObserve = 'body' | 'events' | 'response';
|
||||
* Each request method has multiple signatures, and the return type varies according to which
|
||||
* signature is called (mainly the values of `observe` and `responseType`).
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
@Injectable()
|
||||
export class HttpClient {
|
||||
|
@ -14,7 +14,7 @@ interface Update {
|
||||
|
||||
/**
|
||||
* Immutable set of Http headers, with lazy parsing.
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export class HttpHeaders {
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ import {HttpEvent} from './response';
|
||||
* In rare cases, interceptors may wish to completely handle a request themselves,
|
||||
* and not delegate to the remainder of the chain. This behavior is allowed.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export interface HttpInterceptor {
|
||||
/**
|
||||
@ -47,7 +47,7 @@ export interface HttpInterceptor {
|
||||
/**
|
||||
* `HttpHandler` which applies an `HttpInterceptor` to an `HttpRequest`.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export class HttpInterceptorHandler implements HttpHandler {
|
||||
constructor(private next: HttpHandler, private interceptor: HttpInterceptor) {}
|
||||
@ -61,7 +61,7 @@ export class HttpInterceptorHandler implements HttpHandler {
|
||||
* A multi-provider token which represents the array of `HttpInterceptor`s that
|
||||
* are registered.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export const HTTP_INTERCEPTORS = new InjectionToken<HttpInterceptor[]>('HTTP_INTERCEPTORS');
|
||||
|
||||
|
@ -35,7 +35,7 @@ export const JSONP_ERR_WRONG_RESPONSE_TYPE = 'JSONP requests must use Json respo
|
||||
*
|
||||
* In the browser, this should always be the `window` object.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export abstract class JsonpCallbackContext { [key: string]: (data: any) => void; }
|
||||
|
||||
@ -43,7 +43,7 @@ export abstract class JsonpCallbackContext { [key: string]: (data: any) => void;
|
||||
* `HttpBackend` that only processes `HttpRequest` with the JSONP method,
|
||||
* by performing JSONP style requests.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
@Injectable()
|
||||
export class JsonpClientBackend implements HttpBackend {
|
||||
@ -207,7 +207,7 @@ export class JsonpClientBackend implements HttpBackend {
|
||||
* An `HttpInterceptor` which identifies requests with the method JSONP and
|
||||
* shifts them to the `JsonpClientBackend`.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
@Injectable()
|
||||
export class JsonpInterceptor {
|
||||
|
@ -23,7 +23,7 @@ import {HttpXsrfCookieExtractor, HttpXsrfInterceptor, HttpXsrfTokenExtractor, XS
|
||||
*
|
||||
* Meant to be used as a factory function within `HttpClientModule`.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export function interceptingHandler(
|
||||
backend: HttpBackend, interceptors: HttpInterceptor[] | null = []): HttpHandler {
|
||||
@ -40,7 +40,7 @@ export function interceptingHandler(
|
||||
* Ordinarily JSONP callbacks are stored on the `window` object, but this may not exist
|
||||
* in test environments. In that case, callbacks are stored on an anonymous object instead.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export function jsonpCallbackContext(): Object {
|
||||
if (typeof window === 'object') {
|
||||
@ -59,7 +59,7 @@ export function jsonpCallbackContext(): Object {
|
||||
* If no such names are provided, the default is to use `X-XSRF-TOKEN` for
|
||||
* the header name and `XSRF-TOKEN` for the cookie name.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
@NgModule({
|
||||
providers: [
|
||||
@ -107,7 +107,7 @@ export class HttpClientXsrfModule {
|
||||
* Interceptors can be added to the chain behind `HttpClient` by binding them
|
||||
* to the multiprovider for `HTTP_INTERCEPTORS`.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
@NgModule({
|
||||
imports: [
|
||||
@ -140,7 +140,7 @@ export class HttpClientModule {
|
||||
* Without this module, Jsonp requests will reach the backend
|
||||
* with method JSONP, where they'll be rejected.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
@NgModule({
|
||||
providers: [
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
* Used by `HttpParams`.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
**/
|
||||
export interface HttpParameterCodec {
|
||||
encodeKey(key: string): string;
|
||||
@ -25,7 +25,7 @@ export interface HttpParameterCodec {
|
||||
* A `HttpParameterCodec` that uses `encodeURIComponent` and `decodeURIComponent` to
|
||||
* serialize and parse URL parameter keys and values.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export class HttpUrlEncodingCodec implements HttpParameterCodec {
|
||||
encodeKey(k: string): string { return standardEncoding(k); }
|
||||
@ -79,7 +79,7 @@ interface Update {
|
||||
*
|
||||
* This class is immutable - all mutation operations return a new instance.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export class HttpParams {
|
||||
private map: Map<string, string[]>|null;
|
||||
|
@ -73,7 +73,7 @@ function isFormData(value: any): value is FormData {
|
||||
* assumed to be immutable. To modify a `HttpRequest`, the `clone`
|
||||
* method should be used.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export class HttpRequest<T> {
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ import {HttpHeaders} from './headers';
|
||||
/**
|
||||
* Type enumeration for the different kinds of `HttpEvent`.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export enum HttpEventType {
|
||||
/**
|
||||
@ -48,7 +48,7 @@ export enum HttpEventType {
|
||||
/**
|
||||
* Base interface for progress events.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export interface HttpProgressEvent {
|
||||
/**
|
||||
@ -71,7 +71,7 @@ export interface HttpProgressEvent {
|
||||
/**
|
||||
* A download progress event.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export interface HttpDownloadProgressEvent extends HttpProgressEvent {
|
||||
type: HttpEventType.DownloadProgress;
|
||||
@ -87,7 +87,7 @@ export interface HttpDownloadProgressEvent extends HttpProgressEvent {
|
||||
/**
|
||||
* An upload progress event.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export interface HttpUploadProgressEvent extends HttpProgressEvent {
|
||||
type: HttpEventType.UploadProgress;
|
||||
@ -98,7 +98,7 @@ export interface HttpUploadProgressEvent extends HttpProgressEvent {
|
||||
* when a request may be retried multiple times, to distinguish between
|
||||
* retries on the final event stream.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export interface HttpSentEvent { type: HttpEventType.Sent; }
|
||||
|
||||
@ -108,7 +108,7 @@ export interface HttpSentEvent { type: HttpEventType.Sent; }
|
||||
* Grouping all custom events under this type ensures they will be handled
|
||||
* and forwarded by all implementations of interceptors.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export interface HttpUserEvent<T> { type: HttpEventType.User; }
|
||||
|
||||
@ -118,7 +118,7 @@ export interface HttpUserEvent<T> { type: HttpEventType.User; }
|
||||
*
|
||||
* It bundles the Error object with the actual response body that failed to parse.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export interface HttpJsonParseError {
|
||||
error: Error;
|
||||
@ -130,7 +130,7 @@ export interface HttpJsonParseError {
|
||||
*
|
||||
* Typed according to the expected type of the response.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export type HttpEvent<T> =
|
||||
HttpSentEvent | HttpHeaderResponse | HttpResponse<T>| HttpProgressEvent | HttpUserEvent<T>;
|
||||
@ -138,7 +138,7 @@ export type HttpEvent<T> =
|
||||
/**
|
||||
* Base class for both `HttpResponse` and `HttpHeaderResponse`.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export abstract class HttpResponseBase {
|
||||
/**
|
||||
@ -206,7 +206,7 @@ export abstract class HttpResponseBase {
|
||||
* `HttpHeaderResponse` is a `HttpEvent` available on the response
|
||||
* event stream, only when progress events are requested.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export class HttpHeaderResponse extends HttpResponseBase {
|
||||
/**
|
||||
@ -247,7 +247,7 @@ export class HttpHeaderResponse extends HttpResponseBase {
|
||||
* `HttpResponse` is a `HttpEvent` available on the response event
|
||||
* stream.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export class HttpResponse<T> extends HttpResponseBase {
|
||||
/**
|
||||
@ -297,7 +297,7 @@ export class HttpResponse<T> extends HttpResponseBase {
|
||||
* will contain either a wrapped Error object or the error response returned
|
||||
* from the server.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export class HttpErrorResponse extends HttpResponseBase implements Error {
|
||||
readonly name = 'HttpErrorResponse';
|
||||
|
@ -34,14 +34,14 @@ function getResponseUrl(xhr: any): string|null {
|
||||
/**
|
||||
* A wrapper around the `XMLHttpRequest` constructor.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export abstract class XhrFactory { abstract build(): XMLHttpRequest; }
|
||||
|
||||
/**
|
||||
* A factory for @{link HttpXhrBackend} that uses the `XMLHttpRequest` browser API.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
@Injectable()
|
||||
export class BrowserXhr implements XhrFactory {
|
||||
@ -63,7 +63,7 @@ interface PartialResponse {
|
||||
* An `HttpBackend` which uses the XMLHttpRequest API to send
|
||||
* requests to a backend server.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
@Injectable()
|
||||
export class HttpXhrBackend implements HttpBackend {
|
||||
|
@ -21,7 +21,7 @@ export const XSRF_HEADER_NAME = new InjectionToken<string>('XSRF_HEADER_NAME');
|
||||
/**
|
||||
* Retrieves the current XSRF token to use with the next outgoing request.
|
||||
*
|
||||
* @experimental
|
||||
* @stable
|
||||
*/
|
||||
export abstract class HttpXsrfTokenExtractor {
|
||||
/**
|
||||
|
Reference in New Issue
Block a user