0

Can I use QUIC with HTTP 1 (in Android). I have been reading that QUIC works with HTTP 2 but when I used it with HTTP 1 then my HTTP connection time improved.

I was using

urlConnection = (HttpsURLConnection) url.openConnection();
stream = urlConnection.getInputStream();

after QUIC it is:

 val engine: CronetEngine =
            engineBuilder.enableHttp2(true).enableBrotli(true).enableQuic(true).enableHttpCache(
                CronetEngine.Builder.HTTP_CACHE_IN_MEMORY,
                (100 * 1024).toLong()
            ).build()

 val stream: StreamHandler =
            StreamHandlerFactory(engine).createURLStreamHandler("https") as StreamHandler
 val urlConnection: HttpURLConnection = stream.openConnection(url) as HttpURLConnection

inputStream = urlConnection.getInputStream()

I want to understand why connection time reduced with Quic + HTTP 1 if QUIC only supports HTTP 2

Android14
  • 1,045
  • 1
  • 11
  • 18
  • hm...I'm not sure how cornet works, but I see a `enableHttp2(true)` in your code. Why you say you are using QUIC in HTTP1? – Afshin Dec 24 '21 at 12:25
  • I tried it to reduce connection time (i.e getting an object of input stream from url connection object). Although I enable HTTP2 but the api call that I am making is on HTTP 1.1. – Android14 Dec 26 '21 at 05:11

1 Answers1

0

Answering late here, but Cronet natively supports HTTP, HTTP/2, HTTP/3 over Quic protocols. This is the same library used to power YouTube and other apps - you can read about it in detail here:

https://developer.android.com/guide/topics/connectivity/cronet

You are technically using UDP, and HTTP/1 is over it.

Joe
  • 1,014
  • 1
  • 13
  • 28