Try telling Curl file size (#320)

This commit is contained in:
Gregory Schier 2017-06-21 14:21:45 -07:00 committed by GitHub
parent 041d333be7
commit 272949677b
3 changed files with 3 additions and 2 deletions

View File

@ -106,6 +106,7 @@ Curl.option = {
SSL_VERIFYPEER: 'SSL_VERIFYPEER',
TIMEOUT_MS: 'TIMEOUT_MS',
UPLOAD: 'UPLOAD',
INFILESIZE: 'INFILESIZE',
URL: 'URL',
USERAGENT: 'USERAGENT',
USERNAME: 'USERNAME',

View File

@ -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,

View File

@ -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);