Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URLSession: use http/1.1 instead of http/2

I saw that URLSession supports HTTP 1.1 and HTTP 2 (URLSession supports the HTTP/1.1 and HTTP/2 protocols).

How can I enforce URLSession to use HTTP1.1?

like image 794
swalkner Avatar asked Dec 05 '19 09:12

swalkner


People also ask

How do I change from HTTP 1 to HTTP2?

When to switch? Switching to HTTP/2 is a decision to made after analysing the browser version data of your user base. The HTTP/1.1 to HTTP/2 protocol conversion happens automatically and its backward compatible. So there is nothing pretty much to be done to switch it other than ensuring your server supports it.

Does HTTP2 support HTTP1 1?

Yes, mostly. For HTTP/2 over TLS ( h2 ), if you do not implement the http1. 1 ALPN identifier, then you will not need to support any HTTP/1.1 features. For HTTP/2 over TCP ( h2c ), you need to implement the initial upgrade request.

Does iOS support HTTP2?

The answer here is no: the HTTP/2 support is part of iOS 9, and thus won't be available on earlier OS releases.

How does HTTP1 1 differ from HTTP2?

HTTP2 is much faster and more reliable than HTTP1. HTTP1 loads a single request for every TCP connection, while HTTP2 avoids network delay by using multiplexing. HTTP is a network delay sensitive protocol in the sense that if there is less network delay, then the page loads faster.


2 Answers

Not exactly, there is ALPN negotiation to decide if HTTP/2. If client does not send ALPN, then server should not use HTTP/2.

like image 37
lu fei Avatar answered Nov 15 '22 11:11

lu fei


This is not something determined by the URLSession. It is determined by the server it connects to.

Read more on that here... https://forums.developer.apple.com/thread/94907

like image 186
Fogmeister Avatar answered Nov 15 '22 10:11

Fogmeister