<small id='kmX52'></small><noframes id='kmX52'>

      <tfoot id='kmX52'></tfoot>

      <i id='kmX52'><tr id='kmX52'><dt id='kmX52'><q id='kmX52'><span id='kmX52'><b id='kmX52'><form id='kmX52'><ins id='kmX52'></ins><ul id='kmX52'></ul><sub id='kmX52'></sub></form><legend id='kmX52'></legend><bdo id='kmX52'><pre id='kmX52'><center id='kmX52'></center></pre></bdo></b><th id='kmX52'></th></span></q></dt></tr></i><div id='kmX52'><tfoot id='kmX52'></tfoot><dl id='kmX52'><fieldset id='kmX52'></fieldset></dl></div>

      • <bdo id='kmX52'></bdo><ul id='kmX52'></ul>
      1. <legend id='kmX52'><style id='kmX52'><dir id='kmX52'><q id='kmX52'></q></dir></style></legend>

        内容长度和其他 HTTP 标头?

        时间:2024-08-22
        <i id='DcClf'><tr id='DcClf'><dt id='DcClf'><q id='DcClf'><span id='DcClf'><b id='DcClf'><form id='DcClf'><ins id='DcClf'></ins><ul id='DcClf'></ul><sub id='DcClf'></sub></form><legend id='DcClf'></legend><bdo id='DcClf'><pre id='DcClf'><center id='DcClf'></center></pre></bdo></b><th id='DcClf'></th></span></q></dt></tr></i><div id='DcClf'><tfoot id='DcClf'></tfoot><dl id='DcClf'><fieldset id='DcClf'></fieldset></dl></div>

          <tbody id='DcClf'></tbody>
          <bdo id='DcClf'></bdo><ul id='DcClf'></ul>
        • <small id='DcClf'></small><noframes id='DcClf'>

            <tfoot id='DcClf'></tfoot>

                • <legend id='DcClf'><style id='DcClf'><dir id='DcClf'><q id='DcClf'></q></dir></style></legend>
                  本文介绍了内容长度和其他 HTTP 标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果我在生成普通 HTML 页面时设置此标头是否会给我带来任何好处?

                  Does it give me any advantage if I set this header when generating normal HTML pages?

                  我看到一些框架会设置这个头属性,我想知道为什么......(以及其他标题,例如 Content-Type: text/html)

                  I see that some frameworks out there will set this header property and I was wondering why... (Along with other headers, like Content-Type: text/html)

                  浏览器加载网站是否更快或更流畅?

                  Does browser load the site faster or smoother?

                  ps:他们这样做:

                  ob_start();
                  
                  ... stuff here...
                  
                  $content = ob_get_contents();
                  $length = strlen($content);
                  
                  header('Content-Length: '.$length);
                  
                  echo $content;
                  

                  推荐答案

                  我认为这只是因为 HTTP 规范要求在所有可能的情况下都这样做.

                  I think its only because of the HTTP Spec says to do this in every case possible.

                  应用程序应该使用这个字段来指示消息体的传输长度,除非这被第 4.4 节中的规则禁止.

                  Applications SHOULD use this field to indicate the transfer-length of the message-body, unless this is prohibited by the rules in section 4.4.

                  您还可以查看 在 Pauls Answer 上Deaomon的问题.

                  我想这也会回答你的问题.

                  I think this will answer yours too.

                  如果您希望某人下载带有另一个标题的文件,您还应该使用 Content-Length:例如

                  Also you should use Content-Length if you want someone download a file with another header: e.g.

                  <?php
                  $file = "original.pdf"
                  $size = filesize($file);
                  header('Content-type: application/pdf');
                  header("Content-length: $size");
                  header('Content-Disposition: attachment; filename="downloaded.pdf"');
                  readfile($file);
                  ?>
                  

                  这篇关于内容长度和其他 HTTP 标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL Binary Storage using BLOB VS OS File System:大文件、大数量、大问 下一篇:使用 header() 为动态 pdf 重写 URL 中的文件名

                  相关文章

                  <i id='LD2ST'><tr id='LD2ST'><dt id='LD2ST'><q id='LD2ST'><span id='LD2ST'><b id='LD2ST'><form id='LD2ST'><ins id='LD2ST'></ins><ul id='LD2ST'></ul><sub id='LD2ST'></sub></form><legend id='LD2ST'></legend><bdo id='LD2ST'><pre id='LD2ST'><center id='LD2ST'></center></pre></bdo></b><th id='LD2ST'></th></span></q></dt></tr></i><div id='LD2ST'><tfoot id='LD2ST'></tfoot><dl id='LD2ST'><fieldset id='LD2ST'></fieldset></dl></div>

                    <bdo id='LD2ST'></bdo><ul id='LD2ST'></ul>

                • <tfoot id='LD2ST'></tfoot>

                      <small id='LD2ST'></small><noframes id='LD2ST'>

                    1. <legend id='LD2ST'><style id='LD2ST'><dir id='LD2ST'><q id='LD2ST'></q></dir></style></legend>