85 Commits

Author SHA1 Message Date
Paul Gschwendtner
2d0ff0a5d3 ci: add lint error for files with missing trailing new-line ()
For quite a while it is an unspoken convention to add a trailing
new-line files within the Angular repository. This was never enforced
automatically, but has been frequently raised in pull requests through
manual review. This commit sets up a lint rule so that this is
"officially" enforced and doesn't require manual review.

PR Close 
2021-06-04 13:31:03 -07:00
Ajit Singh
4bc3cf216d feat(common): add URLSearchParams to request body ()
URLSearch params are by default supported in the browser but are not supported by angular/http package added support for URLSearchParams

Fixes 

PR Close 
2021-05-07 10:45:02 -04:00
Gopal Jayaraman
6b8baad940 fix(common): add body as an optional property on the options of HttpClient.delete () ()
adding optional body for HTTP delete request options. This new param added as an optional so won't break the existing code also provide the capability the send the body when and where it required.

PR Close 
2021-05-04 21:09:58 -07:00
Gopal Jayaraman
6e11febf60 fix(common): add right ContentType for boolean values with HttpClient request body() ()
currently a boolean as body is seen as text/plain, where is should be seen as application/json, since it is valid JSON, like numbers.

PR Close 
2021-05-03 10:00:16 -07:00
Alan Agius
e0028e5741 fix(platform-browser): configure XhrFactory to use BrowserXhr ()
With this change we move `XhrFactory` to the root entrypoint of `@angular/commmon`, this is needed so that we can configure `XhrFactory` DI token at a platform level, and not add a dependency  between `@angular/platform-browser` and `@angular/common/http`.

Currently, when using `HttpClientModule` in a child module on the server, `ReferenceError: XMLHttpRequest is not defined` is being thrown because the child module has its own Injector and causes `XhrFactory` provider to be configured to use `BrowserXhr`.
Therefore, we should configure the `XhrFactory` at a platform level similar to other Browser specific providers.

BREAKING CHANGE:

`XhrFactory` has been moved from `@angular/common/http` to `@angular/common`.

**Before**
```ts
import {XhrFactory} from '@angular/common/http';
```

**After**
```ts
import {XhrFactory} from '@angular/common';
```

Closes 

PR Close 
2021-03-29 15:14:16 -07:00
FDIM
1644d64398 feat(compiler-cli): introduce HttpContext request context ()
A long-requested feature for HttpClient is the ability to store and retrieve
custom metadata for requests, especially in interceptors. This commit
implements this functionality via a new context object for requests.

Each outgoing HttpRequest now has an associated "context", an instance of
the HttpContext class. An HttpContext can be provided when making a request,
or if not then an empty context is created for the new request. This context
shares its lifecycle with the entire request, even across operations that
change the identity of the HttpRequest instance such as RxJS retries.

The HttpContext functions as an expando. Users can create typed tokens as instances of HttpContextToken, and
read/write a value for the key from any HttpContext object.

This commit implements the HttpContext functionality. A followup commit will
add angular.io documentation.

PR Close 
2021-03-15 10:33:48 -07:00
Chris
ad40fcae7a docs: improve documentation on how to pass a stringified parameter list to HttpClient ()
Fixes 

PR Close 
2021-03-04 11:00:23 -08:00
cexbrayat
91cdc11aa0 fix(common): allow number or boolean as http params ()
This change fixes an incompatibility between the old `@angular/http` package
and its successor (`@angular/common/http`) by re-introducing the types that were supported before.

It now allows to use number and boolean directly as HTTP params, instead of having to convert it to string first.

Before:

    this.http.get('/api/config', { params: { page: `${page}` } });

After:

    this.http.get('/api/config', { params: { page }});

`HttpParams` has also been updated to have most of its methods accept number or boolean values.

Fixes 

BREAKING CHANGE:

The methods of the `HttpParams` class now accept `string | number | boolean`
instead of `string` for the value of a parameter.
If you extended this class in your application,
you'll have to update the signatures of your methods to reflect these changes.

PR Close 
2021-02-26 12:03:50 -08:00
Jefiozie
f340a5b9f2 fix(http): ignore question mark when params are parsed ()
This commit adds a fix where params will ignore questions marks when
parsed.

Fixes 

PR Close 
2021-02-19 12:11:39 -08:00
Dmitry Drobyshev
38972653fa fix(http): emit error on XMLHttpRequest abort event ()
Before this change, when Google Chrome cancels a XMLHttpRequest, an Observable of the response
never finishes. This happens, for example, when you put your computer to sleep or just press
Ctrl+S to save the browser page. After this commit, if request is canceled or aborted an
appropriate Observable will be completed with an error.

Fixes 

PR Close 
2021-02-10 11:13:05 -08:00
arturovt
61a0b6de6d fix(http): complete the request on timeout ()
When using the [timeout attribute](https://xhr.spec.whatwg.org/#the-timeout-attribute) and an XHR
request times out, browsers trigger the `timeout` event (and execute the XHR's `ontimeout`
callback). Additionally, Safari 9 handles timed-out requests in the same way, even if no `timeout`
has been explicitly set on the XHR.

In the above cases, `HttpClient` would fail to capture the XHR's completing (with an error), so
the corresponding `Observable` would never complete.

PR Close 

PR Close 
2021-02-09 14:44:17 -08:00
Quentin Focheux
6fe3a1de7f feat(http): expose a list of human-readable http status codes ()
They aim to improve code readability.
Since they are defined by `const enum` they have zero runtime performance impact
over just using constant literals.

Fixes 

PR Close 
2021-01-28 09:10:48 -08:00
Harun Urhan
575a2d162c feat(common): implement appendAll() method on HttpParams ()
Adds an `appendAll()` method to `HttpParams` that can construct the HTTP
request/response body from an object of parameters and values.

This avoids calling `append()` multiple times when multiple parameters
need to be added.

Fixes 

PR Close 
2021-01-21 14:01:34 -08:00
Alexey Elin
cf02cf1e18 docs: remove duplicated the ()
PR Close 
2021-01-14 11:33:57 -08:00
Nicholas Papadopoulos
7851a254d8 docs(common): fix typo in HttpClient docs ()
PR Close 
2020-12-02 11:16:43 -08:00
Fabian Wiles
7a5bc95614 refactor(http): inline HttpObserve ()
Inline `HttpObserve` for better type safety.

Fix 

PR Close 
2020-12-01 12:13:04 -08:00
Tzimpoulas Nikos
1539c64fb0 docs(common): change HTTPResponse to HttpResponse ()
PR Close 
2020-11-30 12:04:34 -08:00
Gautier Pelloux-Prayer
938abc03bc docs(http): Add mention to default value 'OK' for statusText. ()
PR Close 
2020-11-23 08:31:24 -08:00
Marcono1234
3e1e5a15ba docs: update links to use HTTPS as protocol ()
PR Close 
2020-11-20 12:52:16 -08:00
Sebastian Häni
39266654e6 fix(http): queue jsonp <script> tag onLoad event handler in microtask ()
Before this change, when trying to load a JSONP script that calls the JSONP callback inside a
microtask, it will fail in Internet Explorer 11 and EdgeHTML. This commit changes the onLoad cleanup
to be queued after the loaded endpoint executed any potential microtask itself. This ensures that
the aforementioned browsers will first evaluate the loaded script calling the JSONP callback and
only then run the cleanup inside onLoad.

Fixes 

PR Close 
2020-11-17 13:09:08 -08:00
Benjamin Qin
75e90fa456 docs(common): update docs for HttpClient methods ()
PR Close 
2020-10-05 12:43:47 -07:00
William Koza
88d7bb8386 fix(http): Fix error message when we call jsonp without importing HttpClientJsonpModule ()
Currently, when we call jsonp method without importing HttpClientJsonpModule, an error message appears saying
'Attempted to construct Jsonp request without JsonpClientModule installed.' instance of 'Attempted to
construct Jsonp request without HttpClientJsonpModule installed.'

PR Close 
2020-09-18 11:20:36 -07:00
Ajit Singh
dd8d8c8289 fix(common): add params and reportProgress options to HttpClient.put() overload ()
When the response type is JSON, the `put()` overload signature did not have `reportProgress`
and  `params` options. This makes it difficult to type-check this overload.

This commit adds them to the overload signature.

Fixes 

PR Close 
2020-09-16 15:28:21 -07:00
Dmitrij Kuba
8a74508130 fix(http): avoid abort a request when fetch operation is completed ()
`abort` method is calling, even if fetch operation is completed

Fixes https://github.com/angular/angular/issues/36537

PR Close 
2020-06-25 12:09:39 -07:00
Joey Perrott
d1ea1f4c7f build: update license headers to reference Google LLC ()
Update the license headers throughout the repository to reference Google LLC
rather than Google Inc, for the required license headers.

PR Close 
2020-05-26 14:26:58 -04:00
Joey Perrott
698b0288be build: reformat repo to new clang@1.4.0 ()
PR Close 
2020-04-14 12:08:36 -07:00
cexbrayat
fcfce99e9e fix(common): remove extra & in http params ()
Previous to this commit, HTTP params like `{ a: '1', b: [], c: '3' }` resulted in a request like `a=1&&c=3` (note the double &&).

The ideal fix would probably be to stringify these params to `a=1&b=&c=3` like we do for empty string values. But that might be breaking as some APIs may rely on the absence of the parameter.

This fixes the issue in a compatible way by just removing the extra and unnecessary `&`, resulting in `a=1&c=3`.

PR Close 
2020-01-31 11:26:25 -08:00
skrikl
0254cba4b3 docs: Fix double 'as an' in description at line 2069 ()
PR Close 
2020-01-07 10:29:41 -08:00
Muhammad Umair
7b87392f47 docs: added value param wrt. method signature ()
PR Close 
2019-11-06 19:51:19 +00:00
Judy Bogart
8321bd8a74 docs: clarify http header api doc ()
PR Close 
2019-10-14 23:45:45 +00:00
Miško Hevery
0c69ec20c2 fix: google3 sync which requires type hints ()
PR Close 
2019-10-11 12:09:20 -07:00
Danny Skoog
6ab5f3648a refactor: utilize type narrowing ()
PR Close 
2019-10-10 15:18:44 -07:00
Judy Bogart
9e7aa60ae7 docs: clarify http response type ()
PR Close 
2019-10-01 11:00:36 -07:00
Mansour Fall
f5bec3ff50 feat(common): HttpParams fromObject accepts ReadonlyArray<string> ()
Fixes 

PR Close 
2019-08-30 12:55:02 -07:00
Judy Bogart
27997a16c0 docs: http api doc edit ()
PR Close 
2019-07-23 21:12:25 -07:00
Paul Gschwendtner
0139b11227 refactor(common): ensure compatibility with typescript strict flag ()
As part of FW-1265, the `@angular/common` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close 
2019-07-18 14:21:26 -07:00
Santosh Yadav
5c18f23788 fix(common): expose the HttpUploadProgressEvent interface as public API ()
Fixes 

PR Close 
2019-06-07 08:47:47 -07:00
JoostK
8e8e89a119 fix(common): prevent repeated application of HttpParams mutations ()
Previously, an instance of HttpParams would retain its list of mutations
after they have been materialized as a result of a read operation. Not
only does this unnecessarily hold onto memory, more importantly does it
introduce a bug where branching of off a materialized instance would
reconsider the set of mutations that had already been applied, resulting
in repeated application of mutations.

This commit fixes the bug by clearing the list of pending mutations
after they have been materialized, such that they will not be considered
once again for branched off instances.

Fixes 

PR Close 
2019-04-23 08:43:54 -07:00
José I. Escudero
0cab43785b docs: fixed typo on HttpParamsOptions ()
PR Close 
2019-04-22 16:36:52 -07:00
Vani
b17d1a9aa3 docs: update description text ()
PR Close 
2019-03-27 09:57:36 -07:00
Vani
60f6d9e733 docs: fix lint error ()
PR Close 
2019-03-27 09:57:36 -07:00
Vani
416b0d29b9 docs: add details to HttpUrlEncodingCodec API description ()
PR Close 
2019-03-27 09:57:36 -07:00
Vani
65d839da03 docs(common): update docs for HttpClient methods ()
PR Close 
2019-02-21 20:56:11 -08:00
Vani
8accc98d28 docs: incorporate review feedback ()
PR Close 
2019-02-14 19:33:14 +00:00
Vani
aa8d0809d3 docs: update HttpInterceptor API docs ()
PR Close 
2019-02-14 19:33:14 +00:00
Vani
c3fadadaa9 docs: update HttpHeader documentation ()
PR Close 
2019-02-07 16:42:13 -08:00
Trotyl Yu
1db53da0d3 fix(common): expose request url in network error ()
closes 

PR Close 
2018-11-27 10:16:22 -08:00
Pete Bacon Darwin
0918adf39d docs: common with @publicApi tags ()
PR Close 
2018-10-19 14:35:53 -07:00
Judy Bogart
dd5e35ee67 docs: add ngmodule api doc ()
PR Close 
2018-09-19 10:40:58 -07:00
Alex Eagle
cbbad1b791 refactor(ivy): pre-factor: set explicit type parameters for ModuleWithProviders ()
Ivy depends on having the generic type token later when reading the ModuleWithProviders from a .d.ts file.

PR Close 
2018-09-18 13:28:44 -07:00