Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix http2 = false having no effect. #2977

Merged
merged 1 commit into from Jun 28, 2019

Conversation

aniketd
Copy link
Contributor

@aniketd aniketd commented Jun 28, 2019

Fixes #2971.

Setting http2 = false in nix config (e.g. /etc/nix/nix.conf)
had no effect, and nix-env -vvvvv -i hello still downloaded .nar
packages using HTTP/2.

In src/libstore/download.cc, the CURL_HTTP_VERSION_2TLS option was
being explicitly set when downloadSettings.enableHttp2 was true,
but, CURL_HTTP_VERSION_1_1 option was not being explicitly set when
downloadSettings.enableHttp2 was false.

This may be because https://curl.haxx.se/libcurl/c/libcurl-env.html states:
"You have to set this option if you want to use libcurl's HTTP/2 support."
but, also, in the changelog, states:
"DEFAULT
Since curl 7.62.0: CURL_HTTP_VERSION_2TLS
Before that: CURL_HTTP_VERSION_1_1"

So, the default setting for libcurl is HTTP/2 for version >= 7.62.0.

In this commit, option CURLOPT_HTTP_VERSION is explicitly set to
CURL_HTTP_VERSION_1_1 when downloadSettings.enableHttp2 nix config
setting is false.

This can be tested by running nix-env -vvvvv -i hello | grep HTTP

cc with @nh2

Setting `http2 = false` in nix config (e.g. /etc/nix/nix.conf)
had no effect, and `nix-env -vvvvv -i hello` still downloaded .nar
packages using HTTP/2.

In `src/libstore/download.cc`, the `CURL_HTTP_VERSION_2TLS` option was
being explicitly set when `downloadSettings.enableHttp2` was `true`,
but, `CURL_HTTP_VERSION_1_1` option was not being explicitly set when
`downloadSettings.enableHttp2` was `false`.

This may be because `https://curl.haxx.se/libcurl/c/libcurl-env.html` states:
"You have to set this option if you want to use libcurl's HTTP/2 support."
but, also, in the changelog, states:
"DEFAULT
Since curl 7.62.0: CURL_HTTP_VERSION_2TLS
Before that: CURL_HTTP_VERSION_1_1"

So, the default setting for `libcurl` is HTTP/2 for version >= 7.62.0.

In this commit, option `CURLOPT_HTTP_VERSION` is explicitly set to
`CURL_HTTP_VERSION_1_1` when `downloadSettings.enableHttp2` nix config
setting is `false`.

This can be tested by running `nix-env -vvvvv -i hello | grep HTTP`
@aniketd aniketd mentioned this pull request Jun 28, 2019
@edolstra edolstra merged commit 5c8f477 into NixOS:master Jun 28, 2019
@edolstra
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot disable http2
3 participants