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.Sessionwas implemented in order to supportsetting cookies, headers and query parameters via
k1=v1;k2=v2strings(in addition to key-value dicts) via the session API and via the CLI:
Since these methods implement logic purely for the
Streamlinksessioninterface and are not meant to be called by any plugin or stream
implementations which use the session's
HTTPSessioninstance, theyshould be removed. Cookies, headers and query string parameters should
be set directly on their respective
HTTPSessionattributes:cookies: instance ofrequests.cookies.RequestsCookieJarheaders: instance ofrequests.structures.CaseInsensitiveDictparams: instance ofdictAlso, at least in regards to HTTP headers, the
key=valuesyntaxdoes not reflect the syntax of raw HTTP requests/responses or interfaces
of other tools like cURL, etc., so having these methods on the
HTTPSessionclass 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=v2string logic from thehttp_sessionmodule to thesessionmodule 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
HTTPSessionfor almost 9 years.This will only affect 3rd party code which is calling these
HTTPSessionmethods. Thekey=valuesyntax is still kept and remains the same on the CLI andStreamlinksession API. See the added tests.Merging this will introduce a conflict with the PR which adds the
http_sessionstub file.