Add option to optionally skip downloading the contents of a file#79
Merged
manuzhang merged 2 commits intomanuzhang:mainfrom Mar 4, 2024
benjamb:max-bytes
Merged
Add option to optionally skip downloading the contents of a file#79manuzhang merged 2 commits intomanuzhang:mainfrom benjamb:max-bytes
manuzhang merged 2 commits intomanuzhang:mainfrom
benjamb:max-bytes
Conversation
benjamb
commented
Mar 1, 2024
htmlproofer/plugin.py
Outdated
Comment on lines
+157
to
+159
| # Download the entire contents as to not break previous behaviour. | ||
| for _ in response.iter_content(chunk_size=1024): | ||
| pass |
Contributor
Author
There was a problem hiding this comment.
If we don't actually care about downloading the contents (we seemingly don't do any verification of contents), then we could always just drop these lines, with stream=True set the body of the response isn't downloaded automatically.
Owner
There was a problem hiding this comment.
We don't as long as the url status is correct.
Contributor
Author
There was a problem hiding this comment.
Should I just simplify this MR to just skip the download entirely and drop the read_max_bytes configuration? I'm hesitant to break existing behaviour, so I'll list out a few possible routes this MR could go:
- Keep this MR as it is, with
read_max_byteslimiting the size of downloaded content. - Opt for a different configuration value, such as
skip_downloads, which triggers this new behaviour of skipping the download of the response's body. - Don't bother adding any configurable behaviour and just establish a connection via
stream=Trueand skip any downloads.
@manuzhang Which would be your preference?
Contributor
Author
There was a problem hiding this comment.
@manuzhang I've implemented option 2 and updated this MR, as well as the original issue title.
manuzhang
approved these changes
Mar 4, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR does a couple of things:
1 . The first commit prevents the downloading of entire files into memory by streaming the response and reading small chunks as a time.
2. The second commit adds the configuration option to optionally skip downloading of a remote URLs content.
Closes #76.