Skip to content

Curl --compressed handling - #1550

Merged
ljharb merged 1 commit into
nvm-sh:masterfrom
JLHwung:curl_compressed_handling
Jun 13, 2017
Merged

ljharb merged 1 commit into
nvm-sh:masterfrom
JLHwung:curl_compressed_handling

Conversation

@JLHwung

@JLHwung JLHwung commented Jun 10, 2017

Copy link
Copy Markdown
Contributor

Added curl_use_compression routine to determine whether we should add compression flag to curl routine. Fixed #1549

curl < 7.21.0 will output redirection reponse body to the output when compressed, which will cause tarball is prepended with redirection reponse body and leads to checksum mismatch.

 - add `nvm_curl_use_compression` and `nvm_curl_version`
Comment thread nvm.sh Outdated

nvm_curl_use_compression() {
if nvm_curl_libz_support && nvm_version_greater_than_or_equal_to nvm_curl_version 7.21.0; then
return 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks amature here to return 0/1, any suggestions from bash pro is welcome.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of the function can just be nvm_curl_libz_support && nvm_version_greater_than_or_equal_to nvm_curl_version 7.21.0

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Please also add a unit test for nvm_curl_use_compression :-)

Comment thread nvm.sh Outdated

nvm_curl_use_compression() {
if nvm_curl_libz_support && nvm_version_greater_than_or_equal_to nvm_curl_version 7.21.0; then
return 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of the function can just be nvm_curl_libz_support && nvm_version_greater_than_or_equal_to nvm_curl_version 7.21.0

Comment thread nvm.sh Outdated
}

nvm_curl_version() {
curl --version | command awk '{ if ($1 == "curl") print $2 }' | command sed 's/-.*$//g'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm_curl_libz_support uses curl -V; are those identical across all curl versions?

If you're not certain, let's stick with curl -V to be consistent.

@JLHwung
JLHwung force-pushed the curl_compressed_handling branch from 6460eae to cb20548 Compare June 11, 2017 16:15
@JLHwung

JLHwung commented Jun 11, 2017

Copy link
Copy Markdown
Contributor Author

Added unit tests of nvm_curl_version as well as nvm_curl_use_compression.

@JLHwung
JLHwung force-pushed the curl_compressed_handling branch from cb20548 to e199e5f Compare June 11, 2017 16:34

if type "curl" > /dev/null 2>&1 ; then
curl_exec="$(type "curl")"
sudo rm -rf "${curl_exec}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is necessary (or safe, since this runs on developer's systems); the function below should mask it sufficiently.

Comment thread test/fast/Unit tests/nvm_curl_version Outdated

if type "curl" > /dev/null 2>&1 ; then
curl_exec="$(type "curl")"
sudo rm -rf "${curl_exec}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@JLHwung

JLHwung commented Jun 13, 2017

Copy link
Copy Markdown
Contributor Author

Removed unnecessary curl mask.

@ljharb ljharb added bugs Oh no, something's broken :-( installing node Issues with installing node/io.js versions. OS: centos labels Jun 13, 2017
@ljharb
ljharb force-pushed the curl_compressed_handling branch from b8c80a5 to 7965796 Compare June 13, 2017 04:38
@ljharb
ljharb merged commit 7965796 into nvm-sh:master Jun 13, 2017
@ljharb

ljharb commented Jun 13, 2017

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugs Oh no, something's broken :-( installing node Issues with installing node/io.js versions. OS: centos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants