apache 如何删除导致Apache 400的大cookie
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2541418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to delete a large cookie that causes Apache to 400
提问by Jake McGraw
I've come across an issue where a web application has managed to create a cookie on the client, which, when submitted by the client to Apache, causes Apache to return the following:
我遇到了一个问题,即 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>
After looking into the issue, it would appear that the web application has managed to create a really long cookie, over 7000 characters. Now, don't ask me how the web application was able to do this, I was under the impression browsers were supposed to prevent this from happening. I've managed to come up with a solution to prevent the cookies from growing out of control again.
在调查该问题后,该 Web 应用程序似乎已成功创建了一个非常长的 cookie,超过 7000 个字符。现在,不要问我 Web 应用程序是如何做到这一点的,我的印象是浏览器应该防止这种情况发生。我设法想出了一个解决方案来防止 cookie 再次失控。
The issue I'm trying to tackle is how do I reset the large cookie on the client if every time the client tries to submit a request to Apache, Apache returns a 400 client error? I've tried using the ErrorDocumentdirective, but it appears that Apache bails on the request before reaching any custom error handling.
我要解决的问题是,如果每次客户端尝试向 Apache 提交请求时,Apache 都会返回 400 客户端错误,我该如何重置客户端上的大 cookie?我已经尝试使用ErrorDocument指令,但似乎 Apache 在达到任何自定义错误处理之前对请求进行了保释。
回答by bobince
Oh dear! I think you'll have to at increase the LimitRequestFieldSizeconfiguration option in Apache's httpd.confto go any further, so you can get as far as running the server-side script. Make sure it cleans up the cookies as quickly as possible before they start to grow again!
哦亲爱的!我认为您必须增加Apache 中的LimitRequestFieldSize配置选项httpd.conf才能更进一步,这样您就可以运行服务器端脚本。确保它在饼干再次开始生长之前尽快清理它们!

