[英].Net Core 3.1 - HTTP request - Send header and body separately
I'm using legacy server, which requires that header and body in HTTP POST requests are sent separately.我正在使用旧服务器,它要求 HTTP POST 请求中的标头和正文分开发送。 I suppose this is achieved with 'Expect: 100-continue', which is present in legacy's client message header.我想这是通过“Expect: 100-continue”实现的,它存在于旧版的客户端消息标头中。
I'm writing new client with use of Net Core 3.1, which seems doesn't have support of Expect100Continue in HttpWebRequest class (According to: https://github.com/dotnet/runtime/issues/25881 )我正在使用 Net Core 3.1 编写新客户端,它似乎不支持 HttpWebRequest 类中的 Expect100Continue(根据: https : //github.com/dotnet/runtime/issues/25881 )
Is there any possibility, to send HTTP request with Net Core 3.1 with separated body and header?有没有可能,用 Net Core 3.1 发送 HTTP 请求,正文和标头分开?
Quick solution was turning off net core's HTTP handler with快速解决方案是关闭 net core 的 HTTP 处理程序
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
After this switch, handler from .net framework is used.在此切换后,将使用 .net 框架中的处理程序。 It looks like that SocketsHttpHandler (at least with combination with HttpWebRequest) doesn't support separated headers and bodies, even when HTTP 1.0 is used.看起来 SocketsHttpHandler (至少与 HttpWebRequest 结合使用)不支持分离的标头和正文,即使使用 HTTP 1.0 也是如此。
https://docs.microsoft.com/en-us/dotnet/api/system.appcontext.setswitch?view=netcore-3.1 https://docs.microsoft.com/en-us/dotnet/api/system.appcontext.setswitch?view=netcore-3.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.