mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Move WRITEFUNCTION definition lower (Fixes #633)
I have no idea why moving this function down works, but it did.
This commit is contained in:
parent
feecc8f203
commit
a0685c882e
@ -471,19 +471,6 @@ export async function _actuallySend (
|
|||||||
setOpt(Curl.option.POSTFIELDS, requestBody);
|
setOpt(Curl.option.POSTFIELDS, requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
let responseBodyBytes = 0;
|
|
||||||
const responsesDir = pathJoin(app.getPath('userData'), 'responses');
|
|
||||||
mkdirp.sync(responsesDir);
|
|
||||||
const responseBodyPath = pathJoin(responsesDir, uuid.v4() + '.response');
|
|
||||||
const responseBodyWriteStream = fs.createWriteStream(responseBodyPath);
|
|
||||||
curl.on('end', () => responseBodyWriteStream.end());
|
|
||||||
curl.on('error', () => responseBodyWriteStream.end());
|
|
||||||
setOpt(Curl.option.WRITEFUNCTION, (buff: Buffer) => {
|
|
||||||
responseBodyBytes += buff.length;
|
|
||||||
responseBodyWriteStream.write(buff);
|
|
||||||
return buff.length;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle Authorization header
|
// Handle Authorization header
|
||||||
if (!hasAuthHeader(headers) && !renderedRequest.authentication.disabled) {
|
if (!hasAuthHeader(headers) && !renderedRequest.authentication.disabled) {
|
||||||
if (renderedRequest.authentication.type === AUTH_BASIC) {
|
if (renderedRequest.authentication.type === AUTH_BASIC) {
|
||||||
@ -562,6 +549,19 @@ export async function _actuallySend (
|
|||||||
.map(h => `${(h.name || '').trim()}: ${h.value}`);
|
.map(h => `${(h.name || '').trim()}: ${h.value}`);
|
||||||
setOpt(Curl.option.HTTPHEADER, headerStrings);
|
setOpt(Curl.option.HTTPHEADER, headerStrings);
|
||||||
|
|
||||||
|
let responseBodyBytes = 0;
|
||||||
|
const responsesDir = pathJoin(app.getPath('userData'), 'responses');
|
||||||
|
mkdirp.sync(responsesDir);
|
||||||
|
const responseBodyPath = pathJoin(responsesDir, uuid.v4() + '.response');
|
||||||
|
const responseBodyWriteStream = fs.createWriteStream(responseBodyPath);
|
||||||
|
curl.on('end', () => responseBodyWriteStream.end());
|
||||||
|
curl.on('error', () => responseBodyWriteStream.end());
|
||||||
|
setOpt(Curl.option.WRITEFUNCTION, (buff: Buffer) => {
|
||||||
|
responseBodyBytes += buff.length;
|
||||||
|
responseBodyWriteStream.write(buff);
|
||||||
|
return buff.length;
|
||||||
|
});
|
||||||
|
|
||||||
// Handle the response ending
|
// Handle the response ending
|
||||||
curl.on('end', async (_1, _2, rawHeaders) => {
|
curl.on('end', async (_1, _2, rawHeaders) => {
|
||||||
const allCurlHeadersObjects = _parseHeaders(rawHeaders);
|
const allCurlHeadersObjects = _parseHeaders(rawHeaders);
|
||||||
|
Loading…
Reference in New Issue
Block a user