plugin.api.http_session: remove parse_* methods #4803
Merged
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.
The
parse_{cookies,headers,query_params}
methods were added when thesubclass of
requests.Session
was implemented in order to supportsetting cookies, headers and query parameters via
k1=v1;k2=v2
strings(in addition to key-value dicts) via the session API and via the CLI:
Since these methods implement logic purely for the
Streamlink
sessioninterface and are not meant to be called by any plugin or stream
implementations which use the session's
HTTPSession
instance, theyshould be removed. Cookies, headers and query string parameters should
be set directly on their respective
HTTPSession
attributes:cookies
: instance ofrequests.cookies.RequestsCookieJar
headers
: instance ofrequests.structures.CaseInsensitiveDict
params
: instance ofdict
Also, at least in regards to HTTP headers, the
key=value
syntaxdoes not reflect the syntax of raw HTTP requests/responses or interfaces
of other tools like cURL, etc., so having these methods on the
HTTPSession
class makes it unnecessarily confusing. The method namesthemselves are also confusing, as they suggest that the input gets
parsed and that some result gets returned, which is wrong.
This commit therefore moves the
k1=v1;k2=v2
string logic from thehttp_session
module to thesession
module where it belongs and italso simplifies the option setter.
This might be a breaking change, not 100% sure, but since this isn't really advertised as a public interface, I don't see the need to document this removal, even though it's been implemented on the
HTTPSession
for almost 9 years.This will only affect 3rd party code which is calling these
HTTPSession
methods. Thekey=value
syntax is still kept and remains the same on the CLI andStreamlink
session API. See the added tests.Merging this will introduce a conflict with the PR which adds the
http_session
stub file.