Php setting the Content-Length browser does not terminate the connection

in terms of online tutorials (for example: http://www.php.cn/php-weiziji.)
use header ("Content-Length: 200"); you can give it a length and stop receiving when it exceeds it, but after I tried, I found that the browser will still download all the content.

Php
Mar.14,2022

there is a problem in that article. The purpose of Content-Length is to solve the problem of requesting to reuse a TCP connection multiple times when a long connection is made. One request is completed by reading only the specified length at a time. This response header needs to be used in conjunction with connection , and it doesn't make sense to add it alone. If you separately set connection to close , this length is useless, because when the connection is closed, the message body is transmitted, so there is no need to specify the length.

the two can only be used together if connection is keep alive .

you can refer to the article https://www.jianshu.com/p/eba..

Menu