What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

前端 未结 22 2683
無奈伤痛
無奈伤痛 2020-12-01 02:24

I\'m currently working on a website, which triggers a net::ERR_HTTP2_PROTOCOL_ERROR 200 error on Google Chrome. I\'m not sure exactly what can provoke this erro

22条回答
  •  [愿得一人]
    2020-12-01 03:10

    For several weeks I was also annoyed by this "bug":

    net :: ERR_HTTP2_PROTOCOL_ERROR 200
    

    In my case, it occurred on images generated by PHP.

    It was at header() level, and on this one in particular:

    header ('Content-Length:'. Filesize($cache_file));
    

    It did obviously not return the exact size, so I deleted it and everything works fine now.

    So Chrome checks the accuracy of the data transmitted via the headers, and if it does not correspond, it fails.

    EDIT

    I found why content-length via filesize was being miscalculated: the GZIP compression is active on the PHP files, so excluding the file in question will fix the problem. Put this code in the .htaccess:

    SetEnvIfNoCase Request_URI ^ / thumb.php no-gzip -vary
    

    It works and we keep the header Content-length.

提交回复
热议问题