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

Handle HTTP redirects using reqwest Client builder #29

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

dongsupark
Copy link
Member

@dongsupark dongsupark commented Nov 17, 2023

To be able to handle HTTP redirects, we need to create reqwest Client with its Client builder, which defaults to 10 attempts on redirects.
Then it is not necessary to do anything again after receiving HTTP response.

Fixes #27
Fixes #17

@pothos
Copy link
Member

pothos commented Nov 17, 2023

With #17 it would be easier to test this

@dongsupark
Copy link
Member Author

Added feature to fetch data from a remote URL.

@dongsupark
Copy link
Member Author

Test like that:

RUST_LOG=debug target/debug/download_sysext -p ~/Dev/kinvolk/flatcar-scripts/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-au-key/files/official-v2.pub.pem -m oem-ami.gz -o /var/tmp/outdir/ -u https://update.release.flatcar-linux.net/amd64-usr/3745.1.0/oem-ami.gz

src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/download.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
src/bin/download_sysext.rs Outdated Show resolved Hide resolved
To be able to handle HTTP redirects, we need to create reqwest Client
with its Client builder, which defaults to 10 attempts on redirects.
Then it is not necessary to do anything again after receiving HTTP
response.
To expose hash_on_disk core logic to other parts like test/update_crau
or download_sysext, move that into a common part in src/download.rs.
Adjust test/crau_verify to make it depend on the new library function
download::hash_on_disk_sha256.
Add new option --payload-url to fetch data from the given URL into
String. Only one of both --input-xml and --payload-url should be given,
otherwil fail.

Construct a fake package to verify signatures in case of a directly
downloaded update payload file. Split the existing signature
verification part into do_download_verify, for the fake pacakage
code path to rely on the common download and verify part.
@dongsupark dongsupark merged commit b20e7b4 into trunk Nov 29, 2023
1 check passed
@dongsupark dongsupark deleted the dongsu/status-redirect branch November 29, 2023 16:33
dongsupark added a commit to flatcar/scripts that referenced this pull request Dec 7, 2023
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.

Handle HTTP redirect status code Download from URL
2 participants