Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private write(
dataToWrite: Buffer,
methodName: string,
options: RequestOptions = {},
retry: boolean = false,
): Promise {
const requestUrl: string =
this.withEndpointPerMethod && retry === false
? `${this.url}/${this.serviceName}/${methodName}`
: this.url
// Merge user options with required options
const requestOptions: RequestOptions & UrlOptions = Core.overlayObjects(
this.requestOptions,
options,
{
method: 'POST',
body: dataToWrite,
encoding: null, // Needs to be explicitly set to null to get Buffer in response body
url: requestUrl,
headers: {
'Content-Length': dataToWrite.length,
'Content-Type': 'application/octet-stream',
},
},
)
return new Promise((resolve, reject) => {
request(