Chunked encoding and content-length header

前端 未结 3 676
太阳男子
太阳男子 2020-12-01 09:34

Is it possible to set the content-length header and also use chunked transfer encoding? and does doing so solve the problem of not knowing the length of the response at the

3条回答
  •  悲哀的现实
    2020-12-01 09:56

    You have to use either Content-Length or chunking, but not both.

    If you know the length in advance, you can use Content-Length instead of chunking even if you generate the content on the fly and never have it all at once in your buffer.

    However, you should not do that if the data is really large because a proxy might not be able to handle it. For large data, chunking is safer.

提交回复
热议问题