From 7d9f1982eba8886ec14871a7a0784a4d501ee148 Mon Sep 17 00:00:00 2001 From: zhaotianff Date: Tue, 18 Oct 2022 11:37:36 +0800 Subject: [PATCH] fix content-type error --- src/Qiniu/Http/HttpManager.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Qiniu/Http/HttpManager.cs b/src/Qiniu/Http/HttpManager.cs index b1098f9..3d202de 100644 --- a/src/Qiniu/Http/HttpManager.cs +++ b/src/Qiniu/Http/HttpManager.cs @@ -112,14 +112,15 @@ public HttpResult Get(string url, StringDictionary headers, string token, bool b wReq.Method = "GET"; if (headers != null) { - foreach (string fieldName in headers.Keys) + if (headers.ContainsKey("Content-Type")) { - wReq.Headers.Add(fieldName, headers[fieldName]); + wReq.ContentType = headers["Content-Type"]; + headers.Remove("Content-Type"); } - if (headers.ContainsKey("Content-Type")) + foreach (string fieldName in headers.Keys) { - wReq.ContentType = headers["Content-Type"]; + wReq.Headers.Add(fieldName, headers[fieldName]); } } if (!string.IsNullOrEmpty(token)) @@ -262,14 +263,15 @@ public HttpResult Post(string url, StringDictionary headers, string token, bool wReq.Method = "POST"; if (headers != null) { - foreach (string fieldName in headers.Keys) + if (headers.ContainsKey("Content-Type")) { - wReq.Headers.Add(fieldName, headers[fieldName]); + wReq.ContentType = headers["Content-Type"]; + headers.Remove("Content-Type"); } - if (headers.ContainsKey("Content-Type")) + foreach (string fieldName in headers.Keys) { - wReq.ContentType = headers["Content-Type"]; + wReq.Headers.Add(fieldName, headers[fieldName]); } } if (!string.IsNullOrEmpty(token))