1
0
mirror of https://github.com/httpie/cli.git synced 2024-11-30 08:46:48 +02:00
httpie-cli/tests
Ilya Sukhanov 147a066dbe
Add internal support for file-like object responses to improve adapter plugin support (#1094)
* Support `requests.response.raw` being a file-like object

Previously HTTPie relied on `requests.models.Response.raw` being
`urllib3.HTTPResponse`. The `requests` documentation specifies that
(requests.models.Response.raw)[https://docs.python-requests.org/en/master/api/#requests.Response.raw]
is a file-like object but allows for other types for internal use.

This change introduces graceful handling for scenarios when
`requests.models.Response.raw` is not `urllib3.HTTPResponse`. In such a scenario
HTTPie now falls back to extracting metadata from `requests.models.Response`
directly instead of direct access from protected protected members such as
`response.raw._original_response`. A side effect in this fallback procedure is
that we can no longer determine HTTP protocol version and report it as `1.1`.

This change is necessary to make it possible to implement `TransportPlugins`
without having to also needing to emulate internal behavior of `urlib3` and
`http.client`.

* Load cookies from `response.headers` instead of `response.raw._original_response.msg._headers`

`response.cookies` was not utilized as it not possible to construct original
payload from `http.cookiejar.Cookie`. Data is stored in lossy format. For example
`Cookie.secure` defaults to `False` so we cannot distinguish if `Cookie.secure` was
set to `False` or was not set at all. Same problem applies to other fields also.

* Simpler HTTP envelope data extraction

* Test cookie extraction and make cookie presentment backwards compatible

Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
2021-07-06 21:00:06 +02:00
..
client_certs Quieten ssl tests (#952) 2020-08-06 22:24:03 +02:00
fixtures Final touches for #1088 (#1091) 2021-06-15 14:48:44 +02:00
utils Final touches for #1088 (#1091) 2021-06-15 14:48:44 +02:00
__init__.py Use relative imports (#1057) 2021-05-05 14:13:39 +02:00
conftest.py Minor clean-up (#1078) 2021-05-29 12:06:06 +02:00
README.rst Update URLs 2020-12-23 22:07:27 +01:00
test_auth_plugins.py Modernize the code base with f-strings in tests (#1069) 2021-05-26 14:09:38 +02:00
test_auth.py Use relative imports (#1057) 2021-05-05 14:13:39 +02:00
test_binary.py Use relative imports (#1057) 2021-05-05 14:13:39 +02:00
test_cli.py Modernize the code base with f-strings in tests (#1069) 2021-05-26 14:09:38 +02:00
test_compress.py Add --raw to allow specifying the raw request body as an alternative to stdin (#1062) 2021-05-24 14:29:54 +02:00
test_config.py Minor clean-up (#1078) 2021-05-29 12:06:06 +02:00
test_cookie.py Add internal support for file-like object responses to improve adapter plugin support (#1094) 2021-07-06 21:00:06 +02:00
test_defaults.py Add --raw to allow specifying the raw request body as an alternative to stdin (#1062) 2021-05-24 14:29:54 +02:00
test_docs.py Fix several issues found with flake8 (#1081) 2021-06-01 14:46:58 +02:00
test_downloads.py Use relative imports (#1057) 2021-05-05 14:13:39 +02:00
test_errors.py Use relative imports (#1057) 2021-05-05 14:13:39 +02:00
test_exit_status.py Use relative imports (#1057) 2021-05-05 14:13:39 +02:00
test_httpie.py Fix several issues found with flake8 (#1081) 2021-06-01 14:46:58 +02:00
test_offline.py Add --raw to allow specifying the raw request body as an alternative to stdin (#1062) 2021-05-24 14:29:54 +02:00
test_output.py Fix several issues found with flake8 (#1081) 2021-06-01 14:46:58 +02:00
test_redirects.py Skip tests that randomly fail on Windows in CI 2021-06-26 14:03:31 +02:00
test_regressions.py Modernize the code base with f-strings in tests (#1069) 2021-05-26 14:09:38 +02:00
test_sessions.py Add internal support for file-like object responses to improve adapter plugin support (#1094) 2021-07-06 21:00:06 +02:00
test_ssl.py Review OSError exceptions handling (#1080) 2021-05-31 10:10:41 +02:00
test_stream.py Use relative imports (#1057) 2021-05-05 14:13:39 +02:00
test_tokens.py Final touches for #1088 (#1091) 2021-06-15 14:48:44 +02:00
test_transport_plugin.py Add internal support for file-like object responses to improve adapter plugin support (#1094) 2021-07-06 21:00:06 +02:00
test_unicode.py Polish Python 2 removal (#1070) 2021-05-27 13:05:41 +02:00
test_uploads.py Minor clean-up (#1078) 2021-05-29 12:06:06 +02:00
test_windows.py Fix several issues found with flake8 (#1081) 2021-06-01 14:46:58 +02:00

HTTPie Test Suite
=================


Please see `CONTRIBUTING`_.


.. _CONTRIBUTING: https://github.com/httpie/httpie/blob/master/CONTRIBUTING.rst