hokaccha / nodebrew

Node.js version manager
MIT License
1.06k stars 66 forks source link

Fix wget fetch_able func to work with HTTP2 or 1.1 #66

Closed shota closed 6 years ago

shota commented 6 years ago

If an user has installed latest wget binary and try to install, it failed because wget try to use HTTP/2. This commit fixes that like curl does.

shota commented 6 years ago

Works with GNU Wget 1.19.1 built on darwin16.4.0.

Response:

wget -Sq --spider "https://nodejs.org/dist/v8.9.4/node-v8.9.4-darwin-x64.tar.gz" 2>&1
  HTTP/1.1 200 OK
  Date: Thu, 22 Feb 2018 05:54:01 GMT
  Content-Type: application/gzip
  Content-Length: 16142777
  Connection: keep-alive
  Set-Cookie: __cfduid=dcb88eaf85d05e21e9418d33143caa0961519278841; expires=Fri, 22-Feb-19 05:54:01 GMT; path=/; domain=.nodejs.org; HttpOnly
  Last-Modified: Wed, 03 Jan 2018 02:32:31 GMT
  ETag: "5a4c40bf-f651b9"
  Accept-Ranges: bytes
  Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
  Server: cloudflare
  CF-RAY: 3f0fb03508449535-NRT
hokaccha commented 6 years ago

I can not reproduce the problem.

test script:

use strict;

my $url = 'https://nodejs.org/dist/v8.9.4/node-v8.9.4-darwin-x64.tar.gz';
print "Version:\n";
system 'wget --version | head -n 1';

print "\nResponse: \n";
system "wget -Sq --spider $url";

print "\nResult: \n";
if (`wget -Sq --spider "$url" 2>&1` =~ m/200 OK/) {
    print 'fetchable';
}
else {
    print 'not fetchable';
}
$ perl test.pl
Version:
GNU Wget 1.19.4 built on darwin15.6.0.

Response:
  HTTP/1.1 200 OK
  Date: Wed, 28 Feb 2018 13:14:42 GMT
  Content-Type: application/gzip
  Content-Length: 16142777
  Connection: keep-alive
  Set-Cookie: __cfduid=da3e049f9ccdb78e65317c5df561727371519823682; expires=Thu, 28-Feb-19 13:14:42 GMT; path=/; domain=.nodejs.org; HttpOnly
  Last-Modified: Wed, 03 Jan 2018 02:32:31 GMT
  ETag: "5a4c40bf-f651b9"
  Accept-Ranges: bytes
  Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
  Server: cloudflare
  CF-RAY: 3f43a5fdee2b9517-NRT

Result:
fetchable

Could you tell me the result that "not fetchable" is displayed?

shota commented 6 years ago

I tried again today and the problem was not reproduced. It's just my mistake or network problem. Thank you for your time.

hokaccha commented 6 years ago

OK, thank you for your reporting!