feat(http): automatically set request Content-Type header based on body type
Implement the ability to provide objects as request body. The following use cases are supported: * raw objects: a JSON payload is created and the content type set to `application/json` * text: the text is used as it is and no content type header is automatically added * URLSearchParams: a form payload is created and the content type set to `application/x-www-form-urlencoded` * FormData: the object is used as it is and no content type header is automatically added * Blob: the object is used as it is and the content type set with the value of its `type` property if any * ArrayBuffer: the object is used as it is and no content type header is automatically added Closes https://github.com/angular/http/issues/69 Closes #7310
This commit is contained in:

committed by
Misko Hevery

parent
e0c83f669e
commit
0f0a8ade7c
@ -36,3 +36,16 @@ export enum ResponseType {
|
||||
Error,
|
||||
Opaque
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported content type to be automatically associated with a {@link Request}.
|
||||
*/
|
||||
export enum ContentType {
|
||||
NONE,
|
||||
JSON,
|
||||
FORM,
|
||||
FORM_DATA,
|
||||
TEXT,
|
||||
BLOB,
|
||||
ARRAY_BUFFER
|
||||
}
|
||||
|
Reference in New Issue
Block a user