调整上传文件时的ContentType赋值顺序问题

This commit is contained in:
Kevin
2017-02-17 02:34:57 +08:00
parent dedb7ce3ae
commit 80e5ac1960
2 changed files with 7 additions and 5 deletions
+5 -3
View File
@@ -94,12 +94,13 @@ namespace OSS.Http
{
string boundary = GetBoundary();
var content= new MultipartFormDataContent(boundary);
content.Headers.TryAddWithoutValidation("Content-Type", $"multipart/form-data;boundary={boundary}");
WriteMultipartFormContent(content, req.FormParameters);
WriteMultipartFormFileContent(content, req.FileParameters);
reqMsg.Content = content;
req.RequestSet?.Invoke(reqMsg); // 位置不能变,防止外部修改 Content-Type
reqMsg.Content.Headers.TryAddWithoutValidation("Content-Type", $"multipart/form-data;boundary={boundary}");
}
else
{
@@ -107,8 +108,9 @@ namespace OSS.Http
reqMsg.Content = new StringContent(data);
reqMsg.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
req.RequestSet?.Invoke(reqMsg);
}
req.RequestSet?.Invoke(reqMsg);
}
+2 -2
View File
@@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0")]
[assembly: AssemblyFileVersion("2.1.0")]
[assembly: AssemblyVersion("2.1.1")]
[assembly: AssemblyFileVersion("2.1.1")]