format
This commit is contained in:
@@ -275,10 +275,11 @@ export class HttpClient {
|
||||
Headers.Accept,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultContentTypeHeader(
|
||||
additionalHeaders,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
additionalHeaders[Headers.ContentType] =
|
||||
this._getExistingOrDefaultContentTypeHeader(
|
||||
additionalHeaders,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
const res: HttpClientResponse = await this.post(
|
||||
requestUrl,
|
||||
data,
|
||||
@@ -298,10 +299,11 @@ export class HttpClient {
|
||||
Headers.Accept,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultContentTypeHeader(
|
||||
additionalHeaders,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
additionalHeaders[Headers.ContentType] =
|
||||
this._getExistingOrDefaultContentTypeHeader(
|
||||
additionalHeaders,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
const res: HttpClientResponse = await this.put(
|
||||
requestUrl,
|
||||
data,
|
||||
@@ -321,10 +323,11 @@ export class HttpClient {
|
||||
Headers.Accept,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultContentTypeHeader(
|
||||
additionalHeaders,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
additionalHeaders[Headers.ContentType] =
|
||||
this._getExistingOrDefaultContentTypeHeader(
|
||||
additionalHeaders,
|
||||
MediaTypes.ApplicationJson
|
||||
)
|
||||
const res: HttpClientResponse = await this.patch(
|
||||
requestUrl,
|
||||
data,
|
||||
@@ -634,30 +637,35 @@ export class HttpClient {
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
const headerValue = lowercaseKeys(this.requestOptions.headers)[header]
|
||||
if (headerValue) {
|
||||
clientHeader = typeof headerValue === 'number' ? headerValue.toString() : headerValue
|
||||
clientHeader =
|
||||
typeof headerValue === 'number' ? headerValue.toString() : headerValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const additionalValue = additionalHeaders[header]
|
||||
|
||||
|
||||
if (additionalValue !== undefined) {
|
||||
return typeof additionalValue === 'number' ? additionalValue.toString() : additionalValue
|
||||
return typeof additionalValue === 'number'
|
||||
? additionalValue.toString()
|
||||
: additionalValue
|
||||
}
|
||||
|
||||
|
||||
if (clientHeader !== undefined) {
|
||||
return clientHeader
|
||||
}
|
||||
|
||||
|
||||
return _default
|
||||
}
|
||||
|
||||
|
||||
private _getExistingOrDefaultContentTypeHeader(
|
||||
additionalHeaders: http.OutgoingHttpHeaders,
|
||||
_default: string
|
||||
): string {
|
||||
let clientHeader: string | undefined
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
const headerValue = lowercaseKeys(this.requestOptions.headers)[Headers.ContentType]
|
||||
const headerValue = lowercaseKeys(this.requestOptions.headers)[
|
||||
Headers.ContentType
|
||||
]
|
||||
if (headerValue) {
|
||||
if (typeof headerValue === 'number') {
|
||||
clientHeader = String(headerValue)
|
||||
@@ -668,9 +676,9 @@ export class HttpClient {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const additionalValue = additionalHeaders[Headers.ContentType]
|
||||
|
||||
|
||||
// Return the first non-undefined value, converting numbers or arrays to strings if necessary
|
||||
if (additionalValue !== undefined) {
|
||||
if (typeof additionalValue === 'number') {
|
||||
@@ -681,11 +689,11 @@ export class HttpClient {
|
||||
return additionalValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (clientHeader !== undefined) {
|
||||
return clientHeader
|
||||
}
|
||||
|
||||
|
||||
return _default
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user