@@ -663,7 +660,7 @@ You can clone and modify the request in a single step, as shown in the following
The `clone()` method's hash argument allows you to mutate specific properties of the request while copying the others.
-#### Mutating a request body
+#### Modifying a request body
The `readonly` assignment guard can't prevent deep updates and, in particular,
it can't prevent you from modifying a property of a request body object.
@@ -672,7 +669,7 @@ it can't prevent you from modifying a property of a request body object.
req.body.name = req.body.name.trim(); // bad idea!
```
-If you must mutate the request body, use the method shown in the following example.
+If you must modify the request body, follow these steps.
1. Copy the body and make your change in the copy.
1. Clone the request object, using its `clone()` method.
@@ -688,7 +685,12 @@ If you must mutate the request body, use the method shown in the following examp
Sometimes you need to clear the request body rather than replace it.
To do this, set the cloned request body to `null`.
-Note that if you set the cloned request body to `undefined`, Angular assumes you intend to leave the body as is.
+
+
+
+**Tip**: If you set the cloned request body to `undefined`, Angular assumes you intend to leave the body as is.
+
+
```javascript
newReq = req.clone({ ... }); // body not mentioned => preserve original body
@@ -725,7 +727,7 @@ An interceptor that alters headers can be used for a number of different operati
### Using interceptors for logging
-Because interceptors can process the request and response _together_, they can do things like time and log an entire HTTP operation.
+Because interceptors can process the request and response _together_, they can perform tasks such as timing and logging an entire HTTP operation.
Consider the following `LoggingInterceptor`, which captures the time of the request,
the time of the response, and logs the outcome with the elapsed time
@@ -770,8 +772,8 @@ to the next handler in the chain.
the cached response, by-passing the `next` handler (and all other interceptors downstream).
* If a cachable request is not in cache, the code calls `sendRequest()`.
-This function creates a [request clone](#immutability) without headers (because the npm API forbids them).
-It forwards the clone of the request to `next.handle()` which ultimately calls the server and returns the server's response.
+This function creates a [request clone](#immutability) without headers, because the npm API forbids them.
+The function then forwards the clone of the request to `next.handle()` which ultimately calls the server and returns the server's response.
{@a send-request}
Note how `sendRequest()` intercepts the response on its way back to the application.
-It pipes the response through the `tap()` operator, whose callback adds the response to the cache.
+This method pipes the response through the `tap()` operator, whose callback adds the response to the cache.
The original response continues untouched back up through the chain of interceptors
to the application caller.
@@ -833,7 +835,7 @@ Subscribers see a sequence of two responses.
Sometimes applications transfer large amounts of data and those transfers can take a long time.
File uploads are a typical example.
-Give the users a better experience by providing feedback on the progress of such transfers.
+You can give the users a better experience by providing feedback on the progress of such transfers.
To make a request with progress events enabled, you can create an instance of `HttpRequest`
with the `reportProgress` option set true to enable tracking of progress events.
@@ -846,9 +848,9 @@ with the `reportProgress` option set true to enable tracking of progress events.
-Every progress event triggers change detection, so only turn them on if you need to report progress in the UI.
+**Tip**: Every progress event triggers change detection, so only turn them on if you need to report progress in the UI.
-When using [`HttpClient.request()`](api/common/http/HttpClient#request) with an HTTP method, configure with
+When using [`HttpClient.request()`](api/common/http/HttpClient#request) with an HTTP method, configure the method with
[`observe: 'events'`](api/common/http/HttpClient#request) to see all events, including the progress of transfers.
@@ -969,7 +971,7 @@ In order to prevent collisions in environments where multiple Angular apps share
*`HttpClient` supports only the client half of the XSRF protection scheme.*
Your backend service must be configured to set the cookie for your page, and to verify that
the header is present on all eligible requests.
-If not, Angular's default protection will be ineffective.
+Failing to do so renders Angular's default protection ineffective.
@@ -994,7 +996,7 @@ The test then expects that certain requests have or have not been made,
performs assertions against those requests,
and finally provides responses by "flushing" each expected request.
-At the end, tests may verify that the app has made no unexpected requests.
+At the end, tests can verify that the app has made no unexpected requests.
@@ -1028,7 +1030,7 @@ the setup of the _service-under-test_.
header="app/testing/http-client.spec.ts(setup)">
-Now requests made in the course of your tests will hit the testing backend instead of the normal backend.
+Now requests made in the course of your tests hit the testing backend instead of the normal backend.
This setup also calls `TestBed.inject()` to inject the `HttpClient` service and the mocking controller
so they can be referenced during the tests.
@@ -1061,7 +1063,7 @@ For example, you could look for an outgoing request that has an authorization he
As with the previous `expectOne()`,
-the test will fail if 0 or 2+ requests satisfy this predicate.
+the test fails if 0 or 2+ requests satisfy this predicate.
#### Handling more than one request