URLSession:使用 http/1.1 而不是 http/2

swa*_*ner 6 nsurlsession swift

我看到 URLSession 支持 HTTP 1.1 和 HTTP 2 ( URLSession supports the HTTP/1.1 and HTTP/2 protocols)。

如何强制 URLSession 使用 HTTP1.1?

Fog*_*ter 6

这不是由URLSession. 它由它连接到的服务器决定。

在这里阅读更多... https://forums.developer.apple.com/thread/94907

  • 因为目前我们使用的工具有 http/2 的错误,并且我们无法在服务器上强制使用 1.1。 (3认同)
  • 当服务器提供 HTTP/2 然后出现错误,但可以使用 HTTP/1.1 时,人们真的希望控制用户代理! (2认同)