Node.js cuts off files when serving over HTTPS

后端 未结 5 1465
醉梦人生
醉梦人生 2021-01-03 00:12

I am trying to serve some JavaScript files with Node.js and for whatever reason the files are being cut off in the middle of the transmission. The code:

http         


        
5条回答
  •  鱼传尺愫
    2021-01-03 00:46

    Instead of Content-Length: data.length you should use Content-Length: Buffer.byteLength(data, 'utf8') where Bufferis a global object (node 0.3.x) or var Buffer = require('buffer') in node 0.2.x which will save you a lot of hassle and might fix your problem with truncated answers too.

提交回复
热议问题