Skip to content

Commit c1f1183

Browse files
committed
fix http header compatibility
1 parent 558cb22 commit c1f1183

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Qiniu/Http/HttpManager.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ public HttpResult Get(string url, StringDictionary headers, string token, bool b
114114
{
115115
foreach (string fieldName in headers.Keys)
116116
{
117-
wReq.Headers.Add(fieldName, headers[fieldName]);
117+
if (!WebHeaderCollection.IsRestricted(fieldName))
118+
{
119+
wReq.Headers.Add(fieldName, headers[fieldName]);
120+
}
118121
}
119122

120123
if (headers.ContainsKey("Content-Type"))
@@ -264,7 +267,10 @@ public HttpResult Post(string url, StringDictionary headers, string token, bool
264267
{
265268
foreach (string fieldName in headers.Keys)
266269
{
267-
wReq.Headers.Add(fieldName, headers[fieldName]);
270+
if (!WebHeaderCollection.IsRestricted(fieldName))
271+
{
272+
wReq.Headers.Add(fieldName, headers[fieldName]);
273+
}
268274
}
269275

270276
if (headers.ContainsKey("Content-Type"))
@@ -1125,7 +1131,10 @@ public HttpResult PostForm(string url, StringDictionary headers, byte[] data, st
11251131
{
11261132
foreach (string fieldName in headers.Keys)
11271133
{
1128-
wReq.Headers.Add(fieldName, headers[fieldName]);
1134+
if (!WebHeaderCollection.IsRestricted(fieldName))
1135+
{
1136+
wReq.Headers.Add(fieldName, headers[fieldName]);
1137+
}
11291138
}
11301139
}
11311140
if (!string.IsNullOrEmpty(token))

0 commit comments

Comments
 (0)