docs(API): 翻译完了 HttpRequest

This commit is contained in:
Zhicheng Wang 2018-09-04 13:55:45 +08:00
parent 785aecb6dd
commit 06368682ef
2 changed files with 53 additions and 1 deletions

View File

@ -56,7 +56,7 @@
[x] | forms/FormControlName | 0.34
[x] | core/Output | 0.33
[x] | common/http/HttpInterceptor | 0.30
[ ] | common/http/HttpRequest | 0.29
[x] | common/http/HttpRequest | 0.29
[ ] | router/CanActivate | 0.27
[ ] | router | 0.26
[ ] | animations/style | 0.25

View File

@ -12,7 +12,11 @@ import {HttpParams} from './params';
/**
* Construction interface for `HttpRequest`s.
*
* `HttpRequest`
*
* All values are optional and will override default values if provided.
*
*
*/
interface HttpRequestInit {
headers?: HttpHeaders;
@ -24,6 +28,8 @@ interface HttpRequestInit {
/**
* Determine whether the given HTTP method may include a body.
*
* `body` HTTP
*/
function mightHaveBody(method: string): boolean {
switch (method) {
@ -41,7 +47,11 @@ function mightHaveBody(method: string): boolean {
/**
* Safely assert whether the given value is an ArrayBuffer.
*
* `ArrayBuffer`
*
* In some execution environments ArrayBuffer is not defined.
*
* `ArrayBuffer`
*/
function isArrayBuffer(value: any): value is ArrayBuffer {
return typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;
@ -50,7 +60,11 @@ function isArrayBuffer(value: any): value is ArrayBuffer {
/**
* Safely assert whether the given value is a Blob.
*
* `Blob`
*
* In some execution environments Blob is not defined.
*
* `Blob`
*/
function isBlob(value: any): value is Blob {
return typeof Blob !== 'undefined' && value instanceof Blob;
@ -59,7 +73,11 @@ function isBlob(value: any): value is Blob {
/**
* Safely assert whether the given value is a FormData instance.
*
* `FormData`
*
* In some execution environments FormData is not defined.
*
* `FormData`
*/
function isFormData(value: any): value is FormData {
return typeof FormData !== 'undefined' && value instanceof FormData;
@ -68,25 +86,37 @@ function isFormData(value: any): value is FormData {
/**
* An outgoing HTTP request with an optional typed body.
*
* HTTP `body`
*
* `HttpRequest` represents an outgoing request, including URL, method,
* headers, body, and other request configuration options. Instances should be
* assumed to be immutable. To modify a `HttpRequest`, the `clone`
* method should be used.
*
* `HttpRequest` URL
* `HttpRequest`使 `clone`
*
*/
export class HttpRequest<T> {
/**
* The request body, or `null` if one isn't set.
*
* `null`
*
* Bodies are not enforced to be immutable, as they can include a reference to any
* user-defined data type. However, interceptors should take care to preserve
* idempotence by treating them as such.
*
*
*
*/
readonly body: T|null = null;
/**
* Outgoing headers for this request.
*
*
*
*/
// TODO(issue/24571): remove '!'.
readonly headers !: HttpHeaders;
@ -94,37 +124,53 @@ export class HttpRequest<T> {
/**
* Whether this request should be made in a way that exposes progress events.
*
*
*
* Progress events are expensive (change detection runs on each event) and so
* they should only be requested if the consumer intends to monitor them.
*
*
*/
readonly reportProgress: boolean = false;
/**
* Whether this request should be sent with outgoing credentials (cookies).
*
* Cookie
*/
readonly withCredentials: boolean = false;
/**
* The expected response type of the server.
*
*
*
* This is used to parse the response appropriately before returning it to
* the requestee.
*
*
*/
readonly responseType: 'arraybuffer'|'blob'|'json'|'text' = 'json';
/**
* The outgoing HTTP request method.
*
* HTTP
*/
readonly method: string;
/**
* Outgoing URL parameters.
*
* URL
*/
// TODO(issue/24571): remove '!'.
readonly params !: HttpParams;
/**
* The outgoing URL with all URL parameters set.
*
* URL URL
*/
readonly urlWithParams: string;
@ -235,6 +281,8 @@ export class HttpRequest<T> {
/**
* Transform the free-form body into a serialized format suitable for
* transmission to the server.
*
*
*/
serializeBody(): ArrayBuffer|Blob|FormData|string|null {
// If no body is present, no need to serialize it.
@ -264,7 +312,11 @@ export class HttpRequest<T> {
* Examine the body and attempt to infer an appropriate MIME type
* for it.
*
* MIME
*
* If no such type can be inferred, this method will return `null`.
*
* MIME `null`
*/
detectContentTypeHeader(): string|null {
// An empty body has no content type.