зеркало из https://github.com/Azure/ms-rest-js.git
Merge pull request #107 from Azure/daschult/contenttype
Add contentType to OperationSpec
This commit is contained in:
Коммит
cb5a1a4829
|
@ -28,6 +28,12 @@ export interface OperationSpec {
|
|||
*/
|
||||
path?: string;
|
||||
|
||||
/**
|
||||
* The content type of the request body. This value will be used as the "Content-Type" header if
|
||||
* it is provided.
|
||||
*/
|
||||
contentType?: string;
|
||||
|
||||
/**
|
||||
* The Mapper that will be used to serialize an HTTP request's body.
|
||||
*/
|
||||
|
|
|
@ -250,6 +250,10 @@ export class ServiceClient {
|
|||
}
|
||||
}
|
||||
|
||||
if (operationSpec.contentType) {
|
||||
httpRequest.headers.set("Content-Type", operationSpec.contentType);
|
||||
}
|
||||
|
||||
if (operationArguments.customHeaders) {
|
||||
for (const customHeaderName in operationArguments.customHeaders) {
|
||||
httpRequest.headers.set(customHeaderName, operationArguments.customHeaders[customHeaderName]);
|
||||
|
|
|
@ -50,12 +50,6 @@ export class WebResource {
|
|||
if (!this.url) {
|
||||
throw new Error("url is a required property for making a request.");
|
||||
}
|
||||
if (!this.headers.get("Content-Type")) {
|
||||
throw new Error("'Content-Type' is a required header for making a request.");
|
||||
}
|
||||
// if (!this.headers["accept-language"]) {
|
||||
// throw new Error("'accept-language' is a required header for making a request.");
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче