Occassionally, I attempt to upload an mp3 to my server, it gets a "400: bad request" error. It sometimes works, sometime doesn't. I want to debug this!
I was wondering if there was a way to log the error via php, and the more verbose reason why it is a bad request? I've searched and cannot find a solution. thanks.
First of all, you have to determine who is responsible for this error: the web server or your PHP code.
grep 400 /path/to/error.log. There will be false positives, of course, but it will give you a starting point. After getting the actual error message from the log, you can Google/chatbot it for the explanation and possible remedies. Like, sometimes PHP devs make a mistake that causes uncontrolled growth for a cookie value, which will eventually cause this error.Another suggestion, which is less scientific but can be quicker, is checking the Dev console in your browser. Since 400 is an HTTP response, it's a problem with HTTP headers. And in the Network tab of Dev console, after selecting the problem request, you can observe the headers and try to spot some abnormality. Such as cookie size, for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With