게시물 요청을 통해 옥텟 스트림으로 .zip 파일 (~ 180KB)을 업로드하려고합니다. 다음 코드는 예상대로 2-3 번 실행됩니다. 파일이 업로드되고 예상대로 응답을받습니다.반복 된 http 게시물 요청이 지연되었습니다.
그러나 3/4 시간 동안 데이터를 게시 할 때 분당 업로드 서버에 요청이 표시되지 않습니다. 잠시 기다리면 다른 2-3 개의 요청을 정상적으로 수행 한 다음 다시 지연 될 수 있습니다.
두 서버 모두 로컬 호스트 (OS X)에서 node (v0.10.31) + express를 실행 중입니다.
노드 v0.10.32 변경 로그에서var options = {
host : interface.host,
port : interface.port,
path : interface.path + '/deployResources',
method : 'POST',
headers : {
'Content-Type': 'application/octet-stream',
'Content-Length': byteLength,
'Content-disposition': 'attachment; filename=resources.zip'
}
};
var stream = fs.createReadStream(zipPath);
var req = http.request(options, function (res) {
// Response delayed on 3rd/4th run
console.log(res.statusCode);
});
stream.on('data', function (data) {
req.write(data);
});
stream.on('end', function() {
console.log('STREAM END');
stream.close();
req.end();
});
:
는HTTP : TE의 HEAD 응답 (표도르 Indutny)
수있는이 0 \ 연구 \ n 개의 \ r \ n을 전송하지 않습니다 문제가 되겠습니까?
감사합니다.
'options' 개체에'agent : false'를 설정하면 어떤 것에 영향을 줍니까? – mscdex
관련없는 메모에서'stream' 이벤트 핸들러를 제거하고'stream.pipe (req);를 수행함으로써 요청 코드를 간소화 할 수 있습니다. – mscdex
에이전트를 false로 설정하면 내 문제가 해결됩니다. 제발 대답을 쓸 수 있니? 감사. – Martin