From 272949677b36d64bc78a7c857f008925cb130377 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 21 Jun 2017 14:21:45 -0700 Subject: [PATCH] Try telling Curl file size (#320) --- app/__mocks__/node-libcurl.js | 1 + app/network/__tests__/network.test.js | 2 +- app/network/network.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/__mocks__/node-libcurl.js b/app/__mocks__/node-libcurl.js index efd340143..ab5421406 100644 --- a/app/__mocks__/node-libcurl.js +++ b/app/__mocks__/node-libcurl.js @@ -106,6 +106,7 @@ Curl.option = { SSL_VERIFYPEER: 'SSL_VERIFYPEER', TIMEOUT_MS: 'TIMEOUT_MS', UPLOAD: 'UPLOAD', + INFILESIZE: 'INFILESIZE', URL: 'URL', USERAGENT: 'USERAGENT', USERNAME: 'USERNAME', diff --git a/app/network/__tests__/network.test.js b/app/network/__tests__/network.test.js index 6cf2dbd7e..27d86fe16 100644 --- a/app/network/__tests__/network.test.js +++ b/app/network/__tests__/network.test.js @@ -259,11 +259,11 @@ describe('actuallySend()', () => { FOLLOWLOCATION: true, HTTPHEADER: [ 'Content-Type: application/octet-stream', - 'Content-Length: 13', 'Expect: ', 'Transfer-Encoding: ' ], NOPROGRESS: false, + INFILESIZE: 13, PROXY: '', NOBODY: 0, TIMEOUT_MS: 0, diff --git a/app/network/network.js b/app/network/network.js index 269609e29..108aa3978 100644 --- a/app/network/network.js +++ b/app/network/network.js @@ -323,8 +323,8 @@ export function _actuallySend (renderedRequest, workspace, settings) { setOpt(Curl.option.HTTPPOST, data); } else if (renderedRequest.body.fileName) { const {size} = fs.statSync(renderedRequest.body.fileName); - headers.push({name: 'Content-Length', value: `${size}`}); const fd = fs.openSync(renderedRequest.body.fileName, 'r+'); + setOpt(Curl.option.INFILESIZE, size); setOpt(Curl.option.UPLOAD, 1); setOpt(Curl.option.READDATA, fd); const fn = () => fs.closeSync(fd);