从服务器收到的重复标头 [英] Duplicate headers received from server
问题描述
从服务器收到重复的标头
Duplicate headers received from server
来自服务器的响应包含重复的标头.此问题通常是错误配置的网站或代理的结果.只有网站或代理管理员可以解决此问题.
The response from the server contained duplicate headers. This problem is generally the result of a misconfigured website or proxy. Only the website or proxy administrator can fix this issue.
错误 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION):收到多个不同的 Content-Disposition 标头.这是不允许的,以防止 HTTP 响应拆分攻击.
Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple distinct Content-Disposition headers received. This is disallowed to protect against HTTP response splitting attacks.
我在 chrome 中导出为 pdf 时发现了这个错误.
I found this error while exporting to pdf in chrome.
Response.Buffer = false;
Response.ClearHeaders();
string ext = objProp.PACKAGEFILENAME.Substring(objProp.PACKAGEFILENAME.LastIndexOf("."));
string ext1 = ext.Substring(1);
Response.ContentType = ext1;
Response.AddHeader("Content-Disposition", "target;_blank,attachment; filename=" + objProp.PACKAGEFILENAME);
const int ChunkSize = 1024;
byte[] binary = objProp.PACKAGEDOCUMENT;
System.IO.MemoryStream ms = new System.IO.MemoryStream(binary);
int SizeToWrite = ChunkSize;
for (int i = 0; i < binary.GetUpperBound(0) - 1; i = i + ChunkSize)
{
if (!Response.IsClientConnected) return;
if (i + ChunkSize >= binary.Length) SizeToWrite = binary.Length - i;
byte[] chunk = new byte[SizeToWrite];
ms.Read(chunk, 0, SizeToWrite);
Response.BinaryWrite(chunk);
Response.Flush();
}
Response.Close();
如何解决这个问题?
推荐答案
这个有点旧,但在谷歌排名中很高,所以我想我会抛出我从 Chrome,pdf 显示,从服务器收到的重复标题
This ones a little old but was high in the google ranking so I thought I would throw in the answer I found from Chrome, pdf display, Duplicate headers received from the server
基本上我的问题也是文件名包含逗号.替换逗号以删除它们,您应该没问题.我制作有效文件名的功能如下.
Basically my problem also was that the filename contained commas. Do a replace on commas to remove them and you should be fine. My function to make a valid filename is below.
public static string MakeValidFileName(string name)
{
string invalidChars = Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars()));
string invalidReStr = string.Format(@"[{0}]+", invalidChars);
string replace = Regex.Replace(name, invalidReStr, "_").Replace(";", "").Replace(",", "");
return replace;
}
这篇关于从服务器收到的重复标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!