New utility class for executing a subprocess and asynchronously reading
its stdout and stderr streams line by line while the process is running,
with an optional timeout which kills the process. The output streams
and exit code get passed to callback methods which can control the
process execution and final output result.
This is useful for validating unknown executables, e.g. when querying
a version string output, as it avoids reading the entire stdout/stderr
at once and also avoids waiting for the process to terminate on its own.
- Add typing information to `Plugin.session`
- Implement `http_session` stub file due to the `HTTPSession` subclass
of `requests.Session` which adds additional keywords to the
`request()` method, including all other HTTP-verb methods
- Add `flake8-pyi` and `typing_extensions` to dev-requirements.txt
(`typing_extensions` is not a runtime dependency)
Install temporary custom lxml wheel on Windows built in an external
repo, as official wheels are missing for Python 3.11. Building it
from source requires building libxml2 and libxslt first and patching
the wheel build config, which is slow and tedious.
The `parse_{cookies,headers,query_params}` methods were added when the
subclass of `requests.Session` was implemented in order to support
setting 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:
- 936e66dd90
- c6e54fd57a
Since these methods implement logic purely for the `Streamlink` session
interface and are not meant to be called by any plugin or stream
implementations which use the session's `HTTPSession` instance, they
should be removed. Cookies, headers and query string parameters should
be set directly on their respective `HTTPSession` attributes:
- `cookies`: instance of `requests.cookies.RequestsCookieJar`
- `headers`: instance of `requests.structures.CaseInsensitiveDict`
- `params`: instance of `dict`
Also, at least in regards to HTTP headers, the `key=value` syntax
does 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 names
themselves 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 the
`http_session` module to the `session` module where it belongs and it
also simplifies the option setter.