You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WinSock套接字合法HTTPS请求头构成及505错误排查

更新:使用简单的HTTP/1.1请求头实现HTTPS。

我在使用WinSock的安全套接字扩展建立HTTPS连接时遇到问题。必须使用SOCKET_SETTINGS_ALLOW_INSECURE(而非SOCKET_SETTINGS_GUARANTEE_ENCRYPTION)才能成功连接,否则会超时。

发送请求头获取资源时,目标网站返回错误响应。Firefox中HTTPS的原始请求头如下:

GET / HTTP/2
Host: www.example.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Pragma: no-cache
Cache-Control: no-cache
TE: trailers

我发送仅包含Accept-Encoding和Upgrade-Insecure-Requests:1的请求头时,收到如下错误:

HTTP/1.1 505 HTTP Version Not Supported
Server: nginx
Date: Wed, 05 Apr 2023 23:57:10 GMT
Content-Type: text/html
Content-Length: 180
Connection: close
Strict-Transport-Security: max-age=31536000
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

我也曾尝试使用HTTP/1.0,但仍无效。推测该网站部署在代理后方,返回的是后端响应,但问题仍未解决。


内容的提问来源于stack exchange,提问作者Mick P.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 12:07:42