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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[networking/rh] Add strict extension checkinge #7604

Merged
merged 13 commits into from Jul 23, 2023

Conversation

coletdjnz
Copy link
Member

@coletdjnz coletdjnz commented Jul 15, 2023

This adds strict checks for extensions in RequestHandlers.

Previously the logic meant any extension received was optional to support. However, this causes issues if an extension is required to be supported for the request.

This PR changes it so RequestHandlers have to specify what extensions they support. If they don't support an extension then the request is marked as unsupported by the handler. This is done through removing extensions from a copy of the extensions dict when checking.

Since the architecture is very new, compat is not a concern yet.

I won't do it as part of this PR, but if we need the support for optional extensions there is lots of ways we can go about adding it if need be, such as :

  • extensions starting with underscore
  • __optional__ extension containing list of optional extensions to ignore
Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

Copilot Summary

馃 Generated by Copilot at 8265877

Summary

馃寪馃И馃敡

This pull request adds support for request extensions to the RequestHandler class and its subclasses, which are used to perform network requests in yt-dlp. It also refactors the extension validation tests in test_networking.py to use a parametrized method.

Oh we are the coders of the sea
We write our RequestHandlers with glee
We check our extensions on the count of three
And raise an UnsupportedRequest if we disagree

Walkthrough

  • Add and document _SUPPORTED_EXTENSIONS attribute to RequestHandler and its subclasses to validate request extensions (link, link, link, link)
  • Implement core extension check in _check_timeout_extension method of RequestHandler to raise UnsupportedRequest exception for unsupported extensions (link)
  • Refactor and parametrize extension tests in test_networking.py using EXTENSION_TESTS attribute and test_extension method (link, link)

@coletdjnz coletdjnz added the enhancement New feature or request label Jul 15, 2023
@pukkandan

This comment was marked as outdated.

yt_dlp/networking/common.py Outdated Show resolved Hide resolved
yt_dlp/networking/_urllib.py Outdated Show resolved Hide resolved
@coletdjnz coletdjnz merged commit 86aea0d into yt-dlp:master Jul 23, 2023
13 checks passed
@coletdjnz coletdjnz deleted the netv2/strict-extensions branch July 23, 2023 05:17
@coletdjnz coletdjnz changed the title [networking/rh] Add strict extension checking [networking/rh] Add strict extension checkinge Oct 7, 2023
aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this pull request Apr 21, 2024
Authored by: coletdjnz
Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants