我正在尝试使用纯nodejs上传文件
var req = require('https').request(myoptions, function afterRequestSend(req,res){
// THIS BLOCK NEVER CALLED. WHY ?
});
var boundayKey = 'abc';
req.write(
'--' + boundaryKey + '\r\n'
+ 'Content-Type: '+ ('application/octet-stream') +'\r\n'
+ 'Content-Disposition: form-data; name="'+ ('file1') +'"; filename="'+ ('filename') +'"\r\n'
);
someReadableStream.pipe(req, { end : false });
someReadableStream.once('end',req.end.bind(req,'\r\n--' + boundaryKey + '--'));
someReadableStream.once('error',reject);
此后它的永无止境的过程
HTTP 17278: sockets service.com:443::::::::: 2
HTTP 17278: write ret = false
HTTP 17278: write ret = false
HTTP 17278: write ret = false
HTTP 17278: write ret = false
HTTP 17278: CLIENT socket onClose
HTTP 17278: removeSocket service.com:443::::::::: writable: false
HTTP 17278: HTTP socket close
HTTP 17278: write ret = true
HTTP 17278: outgoing message end.
永远不会调用after请求回调。 有什么帮助吗?
PS:我不愿意使用任何lib。只是纯粹的nodejs。