(callback)
| 522 | const protocol = (parsed.protocol === 'https:' ? https : http); |
| 523 | |
| 524 | const file = fs.createReadStream(filePath); |
| 525 | const stat = fs.statSync(filePath); |
| 526 | |
| 527 | const options = Object.assign({ |
| 528 | host: parsed.host, |
| 529 | path: parsed.pathname + parsed.search, |
| 530 | method: 'POST', |
| 531 | headers: Object.assign({ |
| 532 | 'Content-Type': 'application/octet-stream', |
| 533 | 'Content-Length': stat.size |
| 534 | }, httpHeaders || {}) |
| 535 | }, httpOptions || {}); |
| 536 | |
| 537 | const req = protocol.request(options, (res) => { |
| 538 | toUtf8(res, (contentType, content) => { |
| 539 | accept({statusCode: res.statusCode, statusMessage: res.statusMessage, content, contentType}); |
| 540 | }, needBinary); |
| 541 | }); |
| 542 | |
| 543 | req.on('error', reject); |
| 544 | file.pipe(req); |
| 545 | }); |
| 546 | } |
| 547 |
no test coverage detected