我如何:
使用字段“ Connection:keep-alive”发出https请求吗?注意:不是“保持活动”,而是“保持活动”。
按我的特定顺序放置标题?
要从“获取行”中删除443吗?
我得到了什么(由提琴手检查):
GET https://test.com:443 HTTP/1.1
Connection: Keep-Alive
Accept-Encoding: gzip, deflate, br
Host: test.com:443
我想要的方式:
GET https://test.com HTTP/1.1
Connection: keep-alive
Host: test.com:443
Accept-Encoding: gzip, deflate, br
这是我的代码:
var client = new HttpClient();
var request = new HttpRequestMessage
{
RequestUri = new Uri("https://test.com"),
Headers =
{
{ "Host", "test.com:443" },
{ "Connection", "keep-alive" },
{ "Accept-Encoding", "gzip, deflate, br" }
}
};
var response = client.SendAsync(request).Result;
我也尝试过:
request.Headers.Add("Connection", "keep-alive"); // 1
request.Headers.Connection.Add("keep-alive"); // 2
client.DefaultRequestHeaders.Add("Connection", "keep-alive"); // 3