我遇到了一个问题:Web 应用程序设法在客户端上创建 cookie,当客户端将其提交给 Apache 时,会导致 Apache 返回以下内容:
HTTP/1.1 400 Bad Request
Date: Mon, 08 Mar 2010 21:21:21 GMT
Server: Apache/2.2.3 (Red Hat)
Content-Length: 7274
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.<br />
<pre>
Cookie: ::: A REALLY LONG COOKIE ::: </pre>
</p>
<hr>
<address>Apache/2.2.3 (Red Hat) Server at www.foobar.com Port 80</address>
</body></html>
调查问题后,网络应用程序似乎已成功创建了一个非常长的 cookie,超过 7000 个字符。现在,不要问我 Web 应用程序是如何做到这一点的,我的印象是浏览器应该阻止这种情况发生。我设法想出了一个解决方案来防止 cookie 再次失控。
我试图解决的问题是,如果每次客户端尝试向 Apache 提交请求时,Apache 返回 400 客户端错误,如何重置客户端上的大 cookie?我尝试过使用 ErrorDocument 指令,但 Apache 在进行任何自定义错误处理之前似乎会放弃该请求。
最佳答案
天哪!我认为你必须增加 LimitRequestFieldSize Apache 的 httpd.conf 中的配置选项可以更进一步,这样您就可以运行服务器端脚本。确保它在 cookies 再次开始生长之前尽快清理它们!
关于apache - 如何删除导致 Apache 400 的大 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2541418/