phpfm
phpfm copied to clipboard
HTTP Error 431 when navigating
After a few minutes of navigation, the script stops working with HTTP error 431. The reason - cookie is too big. It is required to clear the cookie in the browser. If you comment out this line, the problem disappears. https://github.com/dulldusk/phpfm/blob/84a3ee2fe9db4498c390c7d5f6758b0fe78adcf1/index.php#L712
The HTTP 431 Request Header Fields Too Large response status code indicates that the server refuses to process the request because the request’s HTTP headers are too long. The request may be resubmitted after reducing the size of the request headers.
I see.. since the cookie name is based on the folder, and stores the total size as cache. The length of the name and the number of cookies must be surpassing the webserver header default limits. I never got this error, but i have a sollution. I will change the cookie name to an MD5 to short the name. And if i create a function to check the header size and clear the older cookies, i can solve this forever. Without losing the cache functionality.
I will shorten the names for the ACE edit file mode too. And if this is not enough i can start using local storage for the cache, instead of cookies. This too would solve the problem forever.
For now, as a workaround, i released v1.7.9 using md5 to shorten the cookie names. On the latest github version i changed to crc32 hash, that uses only 8 chars for each name. But the real sollution is to use local storage, so this problem never happens again. And i know how to do it properly! Once i have time to spare, i will do it. And if someone is willing to make a donation of $30, i would take it as a job and deliver the update within 7 days.