Node.js cuts off files when serving over HTTPS

后端 未结 5 1466
醉梦人生
醉梦人生 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:28

    It might be a disconnect between the default encoding for readFile and res.end(). readFile just loads the raw data if you do not specify an encoding whereas end() defaults to utf8. I'm not 100% sure but the raw data from the file could return a shorter length than the utf8 encoded string that end emits.

    I tried recreating your error and failed so it might be you need to upgrade your version of node. I'm using the latest code from github.

提交回复
热议问题