Node.js: chunked transfer encoding

前端 未结 3 1720
无人共我
无人共我 2020-12-09 05:41

Is that code valid HTTP/1.1?

var fs = require(\'fs\')
var http = require(\'http\')

var buf=function(res,fd,i,s,buffer){
 if(i+buffer.length

        
3条回答
  •  没有蜡笔的小新
    2020-12-09 06:28

    Since Node.js implicitly sets 'Transfer-Encoding: chunked', all I needed to send in headers was the content type with charset like:

    'Content-Type': 'text/html; charset=UTF-8'
    

    Initially it was:

    'Content-Type': 'text/html'
    

    ... which didn't work. Specifying "charset=UTF-8" immediately forced Chrome to render chunked responses.

提交回复
热议问题