@angular/http

  • Version 7.2.16
  • Published
  • 1.39 MB
  • 1 dependency
  • MIT license

Install

npm i @angular/http
yarn add @angular/http
pnpm add @angular/http

Overview

Angular - the http service

Index

Variables

Functions

Classes

Interfaces

Enums

Variables

variable VERSION

const VERSION: any;
  • Deprecated

    see https://angular.io/guide/http

Functions

function ɵangular_packages_http_http_a

ɵangular_packages_http_http_a: () => CookieXSRFStrategy;

    function ɵangular_packages_http_http_b

    ɵangular_packages_http_http_b: (
    xhrBackend: XHRBackend,
    requestOptions: RequestOptions
    ) => Http;

      function ɵangular_packages_http_http_c

      ɵangular_packages_http_http_c: (
      jsonpBackend: JSONPBackend,
      requestOptions: RequestOptions
      ) => Jsonp;

        Classes

        class BaseRequestOptions

        class BaseRequestOptions extends RequestOptions {}
        • Subclass of RequestOptions, with default values.

          Default values: * method: * headers: empty Headers object

          This class could be extended and bound to the RequestOptions class when configuring an Injector, in order to override the default options used by Http to create and send .

          import {BaseRequestOptions, RequestOptions} from '@angular/http';
          class MyOptions extends BaseRequestOptions {
          search: string = 'coreTeam=true';
          }
          {provide: RequestOptions, useClass: MyOptions};

          The options could also be extended when manually creating a Request object.

          import {BaseRequestOptions, Request, RequestMethod} from '@angular/http';
          const options = new BaseRequestOptions();
          const req = new Request(options.merge({
          method: RequestMethod.Post,
          url: 'https://google.com'
          }));
          console.log('req.method:', RequestMethod[req.method]); // Post
          console.log('options.url:', options.url); // null
          console.log('req.url:', req.url); // https://google.com

          Deprecated

          see https://angular.io/guide/http

        constructor

        constructor();

          class BaseResponseOptions

          class BaseResponseOptions extends ResponseOptions {}
          • Subclass of ResponseOptions, with default values.

            Default values: * status: 200 * headers: empty Headers object

            This class could be extended and bound to the ResponseOptions class when configuring an Injector, in order to override the default options used by Http to create .

            ### Example

            import {provide} from '@angular/core';
            import {bootstrap} from '@angular/platform-browser/browser';
            import {HTTP_PROVIDERS, Headers, Http, BaseResponseOptions, ResponseOptions} from
            '@angular/http';
            import {App} from './myapp';
            class MyOptions extends BaseResponseOptions {
            headers:Headers = new Headers({network: 'github'});
            }
            bootstrap(App, [HTTP_PROVIDERS, {provide: ResponseOptions, useClass: MyOptions}]);

            The options could also be extended when manually creating a Response object.

            ### Example

            import {BaseResponseOptions, Response} from '@angular/http';
            var options = new BaseResponseOptions();
            var res = new Response(options.merge({
            body: 'Angular',
            headers: new Headers({framework: 'angular'})
            }));
            console.log('res.headers.get("framework"):', res.headers.get('framework')); // angular
            console.log('res.text():', res.text()); // Angular;

            Deprecated

            see https://angular.io/guide/http

          constructor

          constructor();

            class BrowserXhr

            class BrowserXhr {}
            • A backend for http that uses the XMLHttpRequest browser API.

              Take care not to evaluate this in non-browser contexts.

              Deprecated

              see https://angular.io/guide/http

            constructor

            constructor();

              method build

              build: () => any;

                class Connection

                abstract class Connection {}
                • Abstract class from which real connections are derived.

                  Deprecated

                  see https://angular.io/guide/http

                property readyState

                readyState: ReadyState;

                  property request

                  request: Request;

                    property response

                    response: any;

                      class ConnectionBackend

                      abstract class ConnectionBackend {}
                      • Abstract class from which real backends are derived.

                        The primary purpose of a ConnectionBackend is to create new connections to fulfill a given Request.

                        Deprecated

                        see https://angular.io/guide/http

                      method createConnection

                      abstract createConnection: (request: any) => Connection;

                        class CookieXSRFStrategy

                        class CookieXSRFStrategy implements XSRFStrategy {}
                        • XSRFConfiguration sets up Cross Site Request Forgery (XSRF) protection for the application using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF) for more information on XSRF.

                          Applications can configure custom cookie and header names by binding an instance of this class with different cookieName and headerName values. See the main HTTP documentation for more details.

                          Deprecated

                          see https://angular.io/guide/http

                        constructor

                        constructor(_cookieName?: string, _headerName?: string);

                          method configureRequest

                          configureRequest: (req: Request) => void;

                            class Headers

                            class Headers {}
                            • Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class).

                              The only known difference between this Headers implementation and the spec is the lack of an entries method.

                              ### Example

                              import {Headers} from '@angular/http';
                              var firstHeaders = new Headers();
                              firstHeaders.append('Content-Type', 'image/jpeg');
                              console.log(firstHeaders.get('Content-Type')) //'image/jpeg'
                              // Create headers from Plain Old JavaScript Object
                              var secondHeaders = new Headers({
                              'X-My-Custom-Header': 'Angular'
                              });
                              console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular'
                              var thirdHeaders = new Headers(secondHeaders);
                              console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular'

                              Deprecated

                              see https://angular.io/guide/http

                            constructor

                            constructor(headers?: Headers | { [name: string]: any });

                              method append

                              append: (name: string, value: string) => void;
                              • Appends a header to existing list of header values for a given header name.

                              method delete

                              delete: (name: string) => void;
                              • Deletes all header values for the given name.

                              method entries

                              entries: () => void;
                              • This method is not implemented.

                              method forEach

                              forEach: (
                              fn: (
                              values: string[],
                              name: string | undefined,
                              headers: Map<string, string[]>
                              ) => void
                              ) => void;

                                method fromResponseHeaderString

                                static fromResponseHeaderString: (headersString: string) => Headers;
                                • Returns a new Headers instance from the given DOMString of Response Headers

                                method get

                                get: (name: string) => string | null;
                                • Returns first header that matches given name.

                                method getAll

                                getAll: (name: string) => string[] | null;
                                • Returns list of header values for a given name.

                                method has

                                has: (name: string) => boolean;
                                • Checks for existence of header by given name.

                                method keys

                                keys: () => string[];
                                • Returns the names of the headers

                                method set

                                set: (name: string, value: string | string[]) => void;
                                • Sets or overrides header value for given name.

                                method toJSON

                                toJSON: () => { [name: string]: any };
                                • Returns string of all headers.

                                method values

                                values: () => string[][];
                                • Returns values of all headers.

                                class Http

                                class Http {}
                                • Performs http requests using XMLHttpRequest as the default backend.

                                  Http is available as an injectable class, with methods to perform http requests. Calling request returns an Observable which will emit a single Response when a response is received.

                                  ### Example

                                  import {Http, HTTP_PROVIDERS} from '@angular/http';
                                  import {map} from 'rxjs/operators';
                                  @Component({
                                  selector: 'http-app',
                                  viewProviders: [HTTP_PROVIDERS],
                                  templateUrl: 'people.html'
                                  })
                                  class PeopleComponent {
                                  constructor(http: Http) {
                                  http.get('people.json')
                                  // Call map on the response observable to get the parsed people object
                                  .pipe(map(res => res.json()))
                                  // Subscribe to the observable to get the parsed people object and attach it to the
                                  // component
                                  .subscribe(people => this.people = people);
                                  }
                                  }

                                  ### Example

                                  http.get('people.json').subscribe((res:Response) => this.people = res.json());

                                  The default construct used to perform requests, XMLHttpRequest, is abstracted as a "Backend" ( XHRBackend in this case), which could be mocked with dependency injection by replacing the XHRBackend provider, as in the following example:

                                  ### Example

                                  import {BaseRequestOptions, Http} from '@angular/http';
                                  import {MockBackend} from '@angular/http/testing';
                                  var injector = Injector.resolveAndCreate([
                                  BaseRequestOptions,
                                  MockBackend,
                                  {provide: Http, useFactory:
                                  function(backend, defaultOptions) {
                                  return new Http(backend, defaultOptions);
                                  },
                                  deps: [MockBackend, BaseRequestOptions]}
                                  ]);
                                  var http = injector.get(Http);
                                  http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res));

                                  Deprecated

                                  see https://angular.io/guide/http

                                constructor

                                constructor(_backend: ConnectionBackend, _defaultOptions: RequestOptions);

                                  method delete

                                  delete: (url: string, options?: RequestOptionsArgs) => any;
                                  • Performs a request with delete http method.

                                  method get

                                  get: (url: string, options?: RequestOptionsArgs) => any;
                                  • Performs a request with get http method.

                                  method head

                                  head: (url: string, options?: RequestOptionsArgs) => any;
                                  • Performs a request with head http method.

                                  method options

                                  options: (url: string, options?: RequestOptionsArgs) => any;
                                  • Performs a request with options http method.

                                  method patch

                                  patch: (url: string, body: any, options?: RequestOptionsArgs) => any;
                                  • Performs a request with patch http method.

                                  method post

                                  post: (url: string, body: any, options?: RequestOptionsArgs) => any;
                                  • Performs a request with post http method.

                                  method put

                                  put: (url: string, body: any, options?: RequestOptionsArgs) => any;
                                  • Performs a request with put http method.

                                  method request

                                  request: (url: string | Request, options?: RequestOptionsArgs) => any;
                                  • Performs any type of http request. First argument is required, and can either be a url or a Request instance. If the first argument is a url, an optional RequestOptions object can be provided as the 2nd argument. The options object will be merged with the values of BaseRequestOptions before performing the request.

                                  class HttpModule

                                  class HttpModule {}
                                  • The module that includes http's providers

                                    Deprecated

                                    see https://angular.io/guide/http

                                  class Jsonp

                                  class Jsonp extends Http {}
                                  • Deprecated

                                    see https://angular.io/guide/http

                                  constructor

                                  constructor(backend: ConnectionBackend, defaultOptions: RequestOptions);

                                    method request

                                    request: (url: string | Request, options?: RequestOptionsArgs) => any;
                                    • Performs any type of http request. First argument is required, and can either be a url or a Request instance. If the first argument is a url, an optional RequestOptions object can be provided as the 2nd argument. The options object will be merged with the values of BaseRequestOptions before performing the request.

                                      Regular XHR is the safest alternative to JSONP for most applications, and is supported by all current browsers. Because JSONP creates a <script> element with contents retrieved from a remote source, attacker-controlled data introduced by an untrusted source could expose your application to XSS risks. Data exposed by JSONP may also be readable by malicious third-party websites. In addition, JSONP introduces potential risk for future security issues (e.g. content sniffing). For more detail, see the [Security Guide](http://g.co/ng/security).

                                    class JSONPBackend

                                    class JSONPBackend extends ConnectionBackend {}
                                    • A ConnectionBackend that uses the JSONP strategy of making requests.

                                      Deprecated

                                      see https://angular.io/guide/http

                                    method createConnection

                                    createConnection: (request: Request) => JSONPConnection;

                                      class JSONPConnection

                                      class JSONPConnection implements Connection {}
                                      • Base class for an in-flight JSONP request.

                                        Deprecated

                                        see https://angular.io/guide/http

                                      property readyState

                                      readyState: ReadyState;

                                      property request

                                      request: Request;
                                      • The outgoing HTTP request.

                                      property response

                                      response: any;
                                      • An observable that completes with the response, when the request is finished.

                                      method finished

                                      finished: (data?: any) => void;
                                      • Callback called when the JSONP request completes, to notify the application of the new data.

                                      class JsonpModule

                                      class JsonpModule {}
                                      • The module that includes jsonp's providers

                                        Deprecated

                                        see https://angular.io/api/common/http/HttpClient#jsonp

                                      class ɵangular_packages_http_http_e

                                      class BrowserJsonp {}

                                        method build

                                        build: (url: string) => any;

                                          method cleanup

                                          cleanup: (node: any) => void;

                                            method exposeConnection

                                            exposeConnection: (id: string, connection: any) => void;

                                              method nextRequestID

                                              nextRequestID: () => string;

                                                method removeConnection

                                                removeConnection: (id: string) => void;

                                                  method requestCallback

                                                  requestCallback: (id: string) => string;

                                                    method send

                                                    send: (node: any) => void;

                                                      class ɵangular_packages_http_http_f

                                                      abstract class Body {}
                                                      • HTTP request body used by both Request and Response https://fetch.spec.whatwg.org/#body

                                                      method arrayBuffer

                                                      arrayBuffer: () => ArrayBuffer;
                                                      • Return the body as an ArrayBuffer

                                                      method blob

                                                      blob: () => Blob;
                                                      • Returns the request's body as a Blob, assuming that body exists.

                                                      method json

                                                      json: () => any;
                                                      • Attempts to return body as parsed JSON object, or raises an exception.

                                                      method text

                                                      text: (encodingHint?: 'legacy' | 'iso-8859') => string;
                                                      • Returns the body as a string, presuming toString() can be called on the response body.

                                                        When decoding an ArrayBuffer, the optional encodingHint parameter determines how the bytes in the buffer will be interpreted. Valid values are:

                                                        - legacy - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly. In addition, the endianness of the 16-bit octet pairs in the ArrayBuffer is not taken into consideration. This is the default behavior to avoid breaking apps, but should be considered deprecated.

                                                        - iso-8859 - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).

                                                      class QueryEncoder

                                                      class QueryEncoder {}
                                                      • Deprecated

                                                        see https://angular.io/guide/http

                                                      method encodeKey

                                                      encodeKey: (key: string) => string;

                                                        method encodeValue

                                                        encodeValue: (value: string) => string;

                                                          class Request

                                                          class Request extends Body {}
                                                          • Creates Request instances from provided values.

                                                            The Request's interface is inspired by the Request constructor defined in the [Fetch Spec](https://fetch.spec.whatwg.org/#request-class), but is considered a static value whose body can be accessed many times. There are other differences in the implementation, but this is the most significant.

                                                            Request instances are typically created by higher-level classes, like Http and Jsonp, but it may occasionally be useful to explicitly create Request instances. One such example is when creating services that wrap higher-level services, like Http, where it may be useful to generate a Request with arbitrary headers and search params.

                                                            import {Injectable, Injector} from '@angular/core';
                                                            import {HTTP_PROVIDERS, Http, Request, RequestMethod} from '@angular/http';
                                                            @Injectable()
                                                            class AutoAuthenticator {
                                                            constructor(public http:Http) {}
                                                            request(url:string) {
                                                            return this.http.request(new Request({
                                                            method: RequestMethod.Get,
                                                            url: url,
                                                            search: 'password=123'
                                                            }));
                                                            }
                                                            }
                                                            var injector = Injector.resolveAndCreate([HTTP_PROVIDERS, AutoAuthenticator]);
                                                            var authenticator = injector.get(AutoAuthenticator);
                                                            authenticator.request('people.json').subscribe(res => {
                                                            //URL should have included '?password=123'
                                                            console.log('people', res.json());
                                                            });

                                                            Deprecated

                                                            see https://angular.io/guide/http

                                                          constructor

                                                          constructor(requestOptions: RequestArgs);

                                                            property headers

                                                            headers: Headers;

                                                            property method

                                                            method: RequestMethod;
                                                            • Http method with which to perform the request.

                                                            property responseType

                                                            responseType: ResponseContentType;
                                                            • Buffer to store the response

                                                            property url

                                                            url: string;
                                                            • Url of the remote resource

                                                            property withCredentials

                                                            withCredentials: boolean;
                                                            • Enable use credentials

                                                            method detectContentType

                                                            detectContentType: () => ContentType;
                                                            • Returns the content type enum based on header options.

                                                            method detectContentTypeFromBody

                                                            detectContentTypeFromBody: () => ContentType;
                                                            • Returns the content type of request's body based on its type.

                                                            method getBody

                                                            getBody: () => any;
                                                            • Returns the request's body according to its type. If body is undefined, return null.

                                                            class RequestOptions

                                                            class RequestOptions {}
                                                            • Creates a request options object to be optionally provided when instantiating a Request.

                                                              This class is based on the RequestInit description in the [Fetch Spec](https://fetch.spec.whatwg.org/#requestinit).

                                                              All values are null by default. Typical defaults can be found in the BaseRequestOptions class, which sub-classes RequestOptions.

                                                              import {RequestOptions, Request, RequestMethod} from '@angular/http';
                                                              const options = new RequestOptions({
                                                              method: RequestMethod.Post,
                                                              url: 'https://google.com'
                                                              });
                                                              const req = new Request(options);
                                                              console.log('req.method:', RequestMethod[req.method]); // Post
                                                              console.log('options.url:', options.url); // https://google.com

                                                              Deprecated

                                                              see https://angular.io/guide/http

                                                            constructor

                                                            constructor(opts?: RequestOptionsArgs);

                                                              property body

                                                              body: any;
                                                              • Body to be used when creating a Request.

                                                              property headers

                                                              headers: Headers;

                                                              property method

                                                              method: string | RequestMethod;
                                                              • Http method with which to execute a Request. Acceptable methods are defined in the RequestMethod enum.

                                                              property params

                                                              params: URLSearchParams;
                                                              • Search parameters to be included in a Request.

                                                              property responseType

                                                              responseType: ResponseContentType;

                                                                property search

                                                                search: URLSearchParams;
                                                                • Deprecated

                                                                  from 4.0.0. Use params instead.

                                                                property url

                                                                url: string;
                                                                • Url with which to perform a Request.

                                                                property withCredentials

                                                                withCredentials: boolean;
                                                                • Enable use credentials for a Request.

                                                                method merge

                                                                merge: (options?: RequestOptionsArgs) => RequestOptions;
                                                                • Creates a copy of the RequestOptions instance, using the optional input as values to override existing values. This method will not change the values of the instance on which it is being called.

                                                                  Note that headers and search will override existing values completely if present in the options object. If these values should be merged, it should be done prior to calling merge on the RequestOptions instance.

                                                                  import {RequestOptions, Request, RequestMethod} from '@angular/http';
                                                                  const options = new RequestOptions({
                                                                  method: RequestMethod.Post
                                                                  });
                                                                  const req = new Request(options.merge({
                                                                  url: 'https://google.com'
                                                                  }));
                                                                  console.log('req.method:', RequestMethod[req.method]); // Post
                                                                  console.log('options.url:', options.url); // null
                                                                  console.log('req.url:', req.url); // https://google.com

                                                                class Response

                                                                class Response extends Body {}
                                                                • Creates Response instances from provided values.

                                                                  Though this object isn't usually instantiated by end-users, it is the primary object interacted with when it comes time to add data to a view.

                                                                  ### Example

                                                                  http.request('my-friends.txt').subscribe(response => this.friends = response.text());

                                                                  The Response's interface is inspired by the Response constructor defined in the [Fetch Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body can be accessed many times. There are other differences in the implementation, but this is the most significant.

                                                                  Deprecated

                                                                  see https://angular.io/guide/http

                                                                constructor

                                                                constructor(responseOptions: ResponseOptions);

                                                                  property bytesLoaded

                                                                  bytesLoaded: number;
                                                                  • Non-standard property

                                                                    Denotes how many of the response body's bytes have been loaded, for example if the response is the result of a progress event.

                                                                  property headers

                                                                  headers: Headers;
                                                                  • Headers object based on the Headers class in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class).

                                                                  property ok

                                                                  ok: boolean;
                                                                  • True if the response's status is within 200-299

                                                                  property status

                                                                  status: number;
                                                                  • Status code returned by server.

                                                                    Defaults to 200.

                                                                  property statusText

                                                                  statusText: string;
                                                                  • Text representing the corresponding reason phrase to the status, as defined in [ietf rfc 2616 section 6.1.1](https://tools.ietf.org/html/rfc2616#section-6.1.1)

                                                                    Defaults to "OK"

                                                                  property totalBytes

                                                                  totalBytes: number;
                                                                  • Non-standard property

                                                                    Denotes how many bytes are expected in the final response body.

                                                                  property type

                                                                  type: ResponseType;
                                                                  • One of "basic", "cors", "default", "error", or "opaque".

                                                                    Defaults to "default".

                                                                  property url

                                                                  url: string;
                                                                  • URL of response.

                                                                    Defaults to empty string.

                                                                  method toString

                                                                  toString: () => string;

                                                                    class ResponseOptions

                                                                    class ResponseOptions {}
                                                                    • Creates a response options object to be optionally provided when instantiating a Response.

                                                                      This class is based on the ResponseInit description in the [Fetch Spec](https://fetch.spec.whatwg.org/#responseinit).

                                                                      All values are null by default. Typical defaults can be found in the BaseResponseOptions class, which sub-classes ResponseOptions.

                                                                      This class may be used in tests to build for mock responses (see MockBackend).

                                                                      ### Example

                                                                      import {ResponseOptions, Response} from '@angular/http';
                                                                      var options = new ResponseOptions({
                                                                      body: '{"name":"Jeff"}'
                                                                      });
                                                                      var res = new Response(options);
                                                                      console.log('res.json():', res.json()); // Object {name: "Jeff"}

                                                                      Deprecated

                                                                      see https://angular.io/guide/http

                                                                    constructor

                                                                    constructor(opts?: ResponseOptionsArgs);

                                                                      property body

                                                                      body: string | Object | ArrayBuffer | Blob;
                                                                      • String, Object, ArrayBuffer or Blob representing the body of the Response.

                                                                      property headers

                                                                      headers: Headers;
                                                                      • Response

                                                                      property status

                                                                      status: number;
                                                                      • Http associated with the response.

                                                                      property url

                                                                      url: string;

                                                                        method merge

                                                                        merge: (options?: ResponseOptionsArgs) => ResponseOptions;
                                                                        • Creates a copy of the ResponseOptions instance, using the optional input as values to override existing values. This method will not change the values of the instance on which it is being called.

                                                                          This may be useful when sharing a base ResponseOptions object inside tests, where certain properties may change from test to test.

                                                                          ### Example

                                                                          import {ResponseOptions, Response} from '@angular/http';
                                                                          var options = new ResponseOptions({
                                                                          body: {name: 'Jeff'}
                                                                          });
                                                                          var res = new Response(options.merge({
                                                                          url: 'https://google.com'
                                                                          }));
                                                                          console.log('options.url:', options.url); // null
                                                                          console.log('res.json():', res.json()); // Object {name: "Jeff"}
                                                                          console.log('res.url:', res.url); // https://google.com

                                                                        class URLSearchParams

                                                                        class URLSearchParams {}
                                                                        • Map-like representation of url search parameters, based on [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard, with several extensions for merging URLSearchParams objects: - setAll() - appendAll() - replaceAll()

                                                                          This class accepts an optional second parameter of $QueryEncoder, which is used to serialize parameters before making a request. By default, QueryEncoder encodes keys and values of parameters using encodeURIComponent, and then un-encodes certain characters that are allowed to be part of the query according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986.

                                                                          These are the characters that are not encoded: ! $ \' ( ) * + , ; A 9 - . _ ~ ? /

                                                                          If the set of allowed query characters is not acceptable for a particular backend, QueryEncoder can be subclassed and provided as the 2nd argument to URLSearchParams.

                                                                          import {URLSearchParams, QueryEncoder} from '@angular/http';
                                                                          class MyQueryEncoder extends QueryEncoder {
                                                                          encodeKey(k: string): string {
                                                                          return myEncodingFunction(k);
                                                                          }
                                                                          encodeValue(v: string): string {
                                                                          return myEncodingFunction(v);
                                                                          }
                                                                          }
                                                                          let params = new URLSearchParams('', new MyQueryEncoder());

                                                                          Deprecated

                                                                          see https://angular.io/guide/http

                                                                        constructor

                                                                        constructor(rawParams?: string, queryEncoder?: QueryEncoder);

                                                                          property paramsMap

                                                                          paramsMap: Map<string, string[]>;

                                                                            property rawParams

                                                                            rawParams: string;

                                                                              method append

                                                                              append: (param: string, val: string) => void;

                                                                                method appendAll

                                                                                appendAll: (searchParams: URLSearchParams) => void;

                                                                                  method clone

                                                                                  clone: () => URLSearchParams;

                                                                                    method delete

                                                                                    delete: (param: string) => void;

                                                                                      method get

                                                                                      get: (param: string) => string | null;

                                                                                        method getAll

                                                                                        getAll: (param: string) => string[];

                                                                                          method has

                                                                                          has: (param: string) => boolean;

                                                                                            method replaceAll

                                                                                            replaceAll: (searchParams: URLSearchParams) => void;

                                                                                              method set

                                                                                              set: (param: string, val: string) => void;

                                                                                                method setAll

                                                                                                setAll: (searchParams: URLSearchParams) => void;

                                                                                                  method toString

                                                                                                  toString: () => string;

                                                                                                    class XHRBackend

                                                                                                    class XHRBackend implements ConnectionBackend {}
                                                                                                    • Creates XHRConnection instances.

                                                                                                      This class would typically not be used by end users, but could be overridden if a different backend implementation should be used, such as in a node backend.

                                                                                                      ### Example

                                                                                                      import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '@angular/http';
                                                                                                      @Component({
                                                                                                      viewProviders: [
                                                                                                      HTTP_PROVIDERS,
                                                                                                      {provide: Http, useFactory: (backend, options) => {
                                                                                                      return new Http(backend, options);
                                                                                                      }, deps: [MyNodeBackend, BaseRequestOptions]}]
                                                                                                      })
                                                                                                      class MyComponent {
                                                                                                      constructor(http:Http) {
                                                                                                      http.request('people.json').subscribe(res => this.people = res.json());
                                                                                                      }
                                                                                                      }

                                                                                                      Deprecated

                                                                                                      see https://angular.io/guide/http

                                                                                                    constructor

                                                                                                    constructor(
                                                                                                    _browserXHR: BrowserXhr,
                                                                                                    _baseResponseOptions: ResponseOptions,
                                                                                                    _xsrfStrategy: XSRFStrategy
                                                                                                    );

                                                                                                      method createConnection

                                                                                                      createConnection: (request: Request) => XHRConnection;

                                                                                                        class XHRConnection

                                                                                                        class XHRConnection implements Connection {}
                                                                                                        • Creates connections using XMLHttpRequest. Given a fully-qualified request, an XHRConnection will immediately create an XMLHttpRequest object and send the request.

                                                                                                          This class would typically not be created or interacted with directly inside applications, though the MockConnection may be interacted with in tests.

                                                                                                          Deprecated

                                                                                                          see https://angular.io/guide/http

                                                                                                        constructor

                                                                                                        constructor(
                                                                                                        req: Request,
                                                                                                        browserXHR: BrowserXhr,
                                                                                                        baseResponseOptions?: ResponseOptions
                                                                                                        );

                                                                                                          property readyState

                                                                                                          readyState: ReadyState;

                                                                                                            property request

                                                                                                            request: Request;

                                                                                                              property response

                                                                                                              response: any;

                                                                                                              method setDetectedContentType

                                                                                                              setDetectedContentType: (req: any, _xhr: any) => void;

                                                                                                                class XSRFStrategy

                                                                                                                abstract class XSRFStrategy {}
                                                                                                                • An XSRFStrategy configures XSRF protection (e.g. via headers) on an HTTP request.

                                                                                                                  Deprecated

                                                                                                                  see https://angular.io/guide/http

                                                                                                                method configureRequest

                                                                                                                abstract configureRequest: (req: Request) => void;

                                                                                                                  Interfaces

                                                                                                                  interface ɵangular_packages_http_http_d

                                                                                                                  interface RequestArgs extends RequestOptionsArgs {}
                                                                                                                  • Required structure when constructing new Request();

                                                                                                                  property url

                                                                                                                  url: string | null;

                                                                                                                    interface RequestOptionsArgs

                                                                                                                    interface RequestOptionsArgs {}
                                                                                                                    • Interface for options to construct a RequestOptions, based on [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.

                                                                                                                      Deprecated

                                                                                                                      see https://angular.io/guide/http

                                                                                                                    property body

                                                                                                                    body?: any;

                                                                                                                      property headers

                                                                                                                      headers?: Headers | null;

                                                                                                                        property method

                                                                                                                        method?: string | RequestMethod | null;

                                                                                                                          property params

                                                                                                                          params?:
                                                                                                                          | string
                                                                                                                          | URLSearchParams
                                                                                                                          | {
                                                                                                                          [key: string]: any | any[];
                                                                                                                          }
                                                                                                                          | null;

                                                                                                                            property responseType

                                                                                                                            responseType?: ResponseContentType | null;

                                                                                                                              property search

                                                                                                                              search?:
                                                                                                                              | string
                                                                                                                              | URLSearchParams
                                                                                                                              | {
                                                                                                                              [key: string]: any | any[];
                                                                                                                              }
                                                                                                                              | null;
                                                                                                                              • Deprecated

                                                                                                                                from 4.0.0. Use params instead.

                                                                                                                              property url

                                                                                                                              url?: string | null;

                                                                                                                                property withCredentials

                                                                                                                                withCredentials?: boolean | null;

                                                                                                                                  interface ResponseOptionsArgs

                                                                                                                                  interface ResponseOptionsArgs {}
                                                                                                                                  • Interface for options to construct a Response, based on [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) from the Fetch spec.

                                                                                                                                    Deprecated

                                                                                                                                    see https://angular.io/guide/http

                                                                                                                                  property body

                                                                                                                                  body?: string | Object | FormData | ArrayBuffer | Blob | null;

                                                                                                                                    property headers

                                                                                                                                    headers?: Headers | null;

                                                                                                                                      property status

                                                                                                                                      status?: number | null;

                                                                                                                                        property statusText

                                                                                                                                        statusText?: string | null;

                                                                                                                                          property type

                                                                                                                                          type?: ResponseType | null;

                                                                                                                                            property url

                                                                                                                                            url?: string | null;

                                                                                                                                              Enums

                                                                                                                                              enum ReadyState

                                                                                                                                              enum ReadyState {
                                                                                                                                              Unsent = 0,
                                                                                                                                              Open = 1,
                                                                                                                                              HeadersReceived = 2,
                                                                                                                                              Loading = 3,
                                                                                                                                              Done = 4,
                                                                                                                                              Cancelled = 5,
                                                                                                                                              }
                                                                                                                                              • All possible states in which a connection can be, based on [States](http://www.w3.org/TR/XMLHttpRequest/#states) from the XMLHttpRequest spec, but with an additional "CANCELLED" state.

                                                                                                                                                Deprecated

                                                                                                                                                see https://angular.io/guide/http

                                                                                                                                              member Cancelled

                                                                                                                                              Cancelled = 5

                                                                                                                                                member Done

                                                                                                                                                Done = 4

                                                                                                                                                  member HeadersReceived

                                                                                                                                                  HeadersReceived = 2

                                                                                                                                                    member Loading

                                                                                                                                                    Loading = 3

                                                                                                                                                      member Open

                                                                                                                                                      Open = 1

                                                                                                                                                        member Unsent

                                                                                                                                                        Unsent = 0

                                                                                                                                                          enum RequestMethod

                                                                                                                                                          enum RequestMethod {
                                                                                                                                                          Get = 0,
                                                                                                                                                          Post = 1,
                                                                                                                                                          Put = 2,
                                                                                                                                                          Delete = 3,
                                                                                                                                                          Options = 4,
                                                                                                                                                          Head = 5,
                                                                                                                                                          Patch = 6,
                                                                                                                                                          }
                                                                                                                                                          • Supported http methods.

                                                                                                                                                            Deprecated

                                                                                                                                                            see https://angular.io/guide/http

                                                                                                                                                          member Delete

                                                                                                                                                          Delete = 3

                                                                                                                                                            member Get

                                                                                                                                                            Get = 0

                                                                                                                                                              member Head

                                                                                                                                                              Head = 5

                                                                                                                                                                member Options

                                                                                                                                                                Options = 4

                                                                                                                                                                  member Patch

                                                                                                                                                                  Patch = 6

                                                                                                                                                                    member Post

                                                                                                                                                                    Post = 1

                                                                                                                                                                      member Put

                                                                                                                                                                      Put = 2

                                                                                                                                                                        enum ResponseContentType

                                                                                                                                                                        enum ResponseContentType {
                                                                                                                                                                        Text = 0,
                                                                                                                                                                        Json = 1,
                                                                                                                                                                        ArrayBuffer = 2,
                                                                                                                                                                        Blob = 3,
                                                                                                                                                                        }
                                                                                                                                                                        • Define which buffer to use to store the response

                                                                                                                                                                          Deprecated

                                                                                                                                                                          see https://angular.io/guide/http

                                                                                                                                                                        member ArrayBuffer

                                                                                                                                                                        ArrayBuffer = 2

                                                                                                                                                                          member Blob

                                                                                                                                                                          Blob = 3

                                                                                                                                                                            member Json

                                                                                                                                                                            Json = 1

                                                                                                                                                                              member Text

                                                                                                                                                                              Text = 0

                                                                                                                                                                                enum ResponseType

                                                                                                                                                                                enum ResponseType {
                                                                                                                                                                                Basic = 0,
                                                                                                                                                                                Cors = 1,
                                                                                                                                                                                Default = 2,
                                                                                                                                                                                Error = 3,
                                                                                                                                                                                Opaque = 4,
                                                                                                                                                                                }
                                                                                                                                                                                • Acceptable response types to be associated with a Response, based on [ResponseType](https://fetch.spec.whatwg.org/#responsetype) from the Fetch spec.

                                                                                                                                                                                  Deprecated

                                                                                                                                                                                  see https://angular.io/guide/http

                                                                                                                                                                                member Basic

                                                                                                                                                                                Basic = 0

                                                                                                                                                                                  member Cors

                                                                                                                                                                                  Cors = 1

                                                                                                                                                                                    member Default

                                                                                                                                                                                    Default = 2

                                                                                                                                                                                      member Error

                                                                                                                                                                                      Error = 3

                                                                                                                                                                                        member Opaque

                                                                                                                                                                                        Opaque = 4

                                                                                                                                                                                          Package Files (17)

                                                                                                                                                                                          Dependencies (1)

                                                                                                                                                                                          Dev Dependencies (0)

                                                                                                                                                                                          No dev dependencies.

                                                                                                                                                                                          Peer Dependencies (3)

                                                                                                                                                                                          Badge

                                                                                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@angular/http.

                                                                                                                                                                                          • Markdown
                                                                                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@angular/http)
                                                                                                                                                                                          • HTML
                                                                                                                                                                                            <a href="https://www.jsdocs.io/package/@angular/http"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>