aslze / asl

A compact C++ cross-platform library including JSON, XML, HTTP, Sockets, WebSockets, threads, processes, logs, file system, CSV, INI files, vectors and matrices, etc.
Other
69 stars 17 forks source link

Can't download GitHub release #12

Closed ghost closed 4 years ago

ghost commented 4 years ago

Code:

#include <iostream>
#include <asl/Http.h>

int main()
{
    std::cout << asl::Http::get("https://github.com/aslze/asl/releases/download/1.9.3/asl-1.9.3.7z").code() << std::endl;
    return 0;
}

Output:

valentin@pop-os:~/Desktop/notworking$ ./build/notworking 
403

Body says The request signature we calculated does not match the signature you provided

aslze commented 4 years ago

I'll take a look. Github redirects release downloads with a 302 to a different very long URL (should work) but may need to set additional headers...

I just tried curl on that URL and it downloads a redirection HTML page with a link, instead of the content.

ghost commented 4 years ago

curl -L https://github.com/aslze/asl/releases/download/1.9.3/asl-1.9.3.7z -o asl.7z works

aslze commented 4 years ago

OK, yes, I didn't know that flag.

Something with AWS pre-signed URLs... I'll take a look later.

ghost commented 4 years ago

fix: remove port in Host header if it's 80 (HTTP) or 443 (HTTPS)

aslze commented 4 years ago

I just fixed this. But the commits in your pull requests seemed incomplete. Did they work for you? You checked url.port != 0 to see if there was no port specified, but a few lines above, that was changed to 80 or 443, so url.port would never be zero. I added another variable that checks if there is a port before it is changed.

Thank you!