Skip to content

Cannot use HTTP/2 #2336

@amrishodiq

Description

@amrishodiq

Hi,
I tried to use OkHttp 3.0.1 to open https://http2.akamai.com/ which is known to be HTTP/2 enabled.
I found that response.protocol() to always returns "http/1.1" instead of "http/2".
I tried both in my desktop and Android.
Here the code I wrote:

        String url = "https://http2.akamai.com/";

        List<Protocol> protocols = new ArrayList<>();
            protocols.add(Protocol.SPDY_3);
            protocols.add(Protocol.HTTP_2);
            protocols.add(Protocol.HTTP_1_1);

        OkHttpClient client = new OkHttpClient.Builder()
                .protocols(protocols)
                .build();
        Request request = new Request.Builder()
            .url(url)
            .build();

        try {
            Response response = client.newCall(request).execute();
            System.out.println("Protocol: "+response.protocol().toString());
        } catch (IOException ex) {
            Logger.getLogger("Test").log(Level.SEVERE, null, ex);
        }

Is it normal?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions