php自帶的webServer解析時出現 Invalid request (Unexpected EOF)報錯!
因硬體需求原因,不能安裝更多應用,需使用php作為服務,於是利用php自帶的webserver搞了一個簡單的檔案管理指令碼。
啟動php server命令:
php -S 127.0.0.1:8088 start.php
執行中發現Linux/Window 7下控制檯都會報 Invalid request (Unexpected EOF)錯誤。
於是,在stackoverflow中找到了答案:
首先,這是一個已知的bug
文中提高有三種可能:
1.php指令碼無閉合標籤。
2.閉合標籤後可能有多餘的空行。
3.谷歌瀏覽器的特性有一個Predict network actions to improve page load performance,預設開啟的。如果無用的tcp連線次數超過10s,php Server也會顯示Invalid request (unexpected EOF)。
[2011-12-08 15:01 UTC] lolautruche at gmail dot com Description:
------------
From time to time, built-in server with router script logs this kind of stuff :
[Thu Dec 8 13:39:29 2011] 127.0.0.1:50358 Invalid request (Unexpected EOF)
This happens quite randomly, whatever the script has a close tag or not, whatever it has a blank line after close tag or not.
Chromium has feature called "Predict network actions to improve page load performance" and its enabled by default. It works this way, that if HTML page has links to some resources, than Chromium opens about 10 TCP connections in advance. And then if browser has less than 10 resources to fetch, unused connections times out after 10 seconds. And this (empty payload) causes PHP server to display "Invalid request (unexpected EOF)" message.
This could be related to Chrome specifically and its network prediction feature. So try to disable that feature first. That's why it works for you in Incognito mode, because probably it's disabled in that mode.
You can find this option in Chrome Settings and click on 'Show advanced settings'. Should be there in Privacy section.
原文連線:
https://stackoverflow.com/questions/29141240/php-local-server-invalid-request-unexpected-eof