Commit Graph

142 Commits

Author SHA1 Message Date
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
Jakub Roztocil
07a0359316
Final touches for #1088 (#1091)
* Make sure there’s no trailing \n in test files for easier output inspection

* Refactor output matching test utils

* More robust `test_http_307_allow_redirect_post_verbose()`

* Changelog

* Mention HTTP 307 Temporary Redirect re-post behaviour in README
2021-06-15 14:48:44 +02:00
Mickaël Schoentgen
0001297f41
Add --raw to allow specifying the raw request body as an alternative to stdin (#1062)
* Add --raw to allow specifying the raw request body without extra processing

As an alternative to `stdin`.

Co-authored-by: Elena Lape <elapinskaite@gmail.com>
Co-authored-by: Jakub Roztocil <jakub@roztocil.co>

* Update README.rst

Co-authored-by: Jakub Roztocil <jakub@roztocil.co>

* Update README.rst

Co-authored-by: Jakub Roztocil <jakub@roztocil.co>

* Fix default HTTP method on empty data

Co-authored-by: Elena Lape <elapinskaite@gmail.com>
Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
2021-05-24 14:29:54 +02:00
Mickaël Schoentgen
e2d43c14ce
Prefer usage of "python -m pip" instead of "pip" (#1059)
* Prefer usage of "python -m pip" instead of "pip"

It will prevent issues when users think that they are using
the correct `pip` version. It can refers to the one from the OS
Python installation, or even worse to a Python 2 installation.
Let's be clear on how to install stuff.

Also used short version of `pip` arguments, because we are all lazy :)

* Apply suggestions from code review
2021-05-05 14:17:04 +02:00
Jakub Roztocil
cc20488f49 Formatting 2021-02-14 13:34:20 +01:00
Jakub Roztocil
b918972862 CHANGELOG #1032 2021-02-14 13:33:38 +01:00
Jakub Roztocil
e944dbd7fa 2.5.0-dev 2021-02-06 13:34:04 +01:00
Jakub Roztocil
5d5a8b4091 Typo 2021-02-06 11:26:15 +01:00
Jakub Roztocil
bb36897054 2.4.0 2021-02-06 11:17:24 +01:00
Jakub Roztocil
d014498713 Changelog entry for cookie expiration based on Set-Cookie: max-age=<n>
#1029
2021-02-06 11:02:26 +01:00
Jakub Roztocil
cf78a12e46
Show --check-status warning with --quiet as well. (#1026)
Fixes #1028
2021-01-31 00:58:56 +01:00
Jakub Roztocil
0f1e098cc4
Fix incorrect separators and introduce assert_output_matches() (close #1027) 2021-01-30 22:14:57 +01:00
Jakub Roztocil
77b8c37cb0 Update changelog
#1020
2021-01-13 21:49:53 +01:00
Jakub Roztocil
6922a0c912 Switch from httpbin.org to pie.dev 2020-12-24 21:34:30 +01:00
Jakub Roztocil
2afdc958c6 Update URLs 2020-12-23 22:07:27 +01:00
Jakub Roztocil
42c4a7596b 2.4.0-dev 2020-10-25 21:36:24 +01:00
Jakub Roztocil
1573058811 v2.3.0 2020-10-25 21:12:38 +01:00
Jakub Roztocil
6925d930da Add support for streamed uploads, --chunked, finish --multipart, etc.
Close #201
Close #753
Close #684
Close #903
Related: #452
2020-09-28 12:16:57 +02:00
Jakub Roztocil
c431ed7728 CHANGELOG
#963
2020-09-20 09:30:18 +02:00
Jakub Roztocil
1813cf6156 Add --multipart and --boundary 2020-08-19 10:22:50 +02:00
Jakub Roztocil
6cd934d1b8 Add support for multipart upload streaming
Close #684, #201
2020-08-15 17:50:00 +02:00
Jakub Roztocil
1aa1366f99 Finish --quiet 2020-08-15 15:26:29 +02:00
Nicolas Beltran
6421c145d9 Added changes suggested in the PR review 2020-08-15 15:26:29 +02:00
Nicolas Beltran
61e7cd786e Added a documentation entry and modified CHANGELOG 2020-08-15 15:26:29 +02:00
Shageldi Ovezov
cf937b6b79
Remove tox (#944)
* Removed the instructions of tox testing

* Deleted tox.ini

* removed tox from requirements

* removed tox from setup.cfg

* removed tox from the Makefile

* removed tox from contributing docs

* updated the CHANGELOG

* removed tox from .gitignore
2020-06-26 17:22:06 +02:00
Jakub Roztocil
55d7af86fd Install requests[socks] by default for out of the box SOCKS support
Close #904
2020-06-19 00:56:30 +02:00
Jakub Roztocil
ecdeffe7c8 CHANGELOG + README 2020-06-18 23:23:10 +02:00
Jakub Roztocil
93d07cfe57 v2.3.0-dev 2020-06-18 22:25:07 +02:00
Jakub Roztocil
5945845420 v2.2.0 2020-06-18 22:20:12 +02:00
Jakub Roztocil
d35864e79d Cleanup 2020-06-16 13:01:48 +02:00
Jakub Roztocil
8a106781be Add --sorted
Also add --no-(sorted|unsorted) to allow the documented resetting to default via --no-<option>.
2020-06-16 12:54:50 +02:00
Jakub Roztocil
826489950d Added --unsorted
It acts as a shortcut for --format-options=json.sort_keys:false,headers.sort:false

#128
2020-06-16 12:20:13 +02:00
Jakub Roztocil
b86598886e Added netrc support for auth plugins.
Enabled for --auth-type=basic and digest, 3rd parties may opt in.

This closes #718, closes #719, closes #852, and also closes #934
2020-06-16 11:05:00 +02:00
Jakub Roztocil
26e29612f2 Update CHANGELOG.rst 2020-06-15 23:08:09 +02:00
Jakub Roztocil
7ee519ef46 Update CHANGELOG 2020-06-08 18:02:04 +02:00
Carlo Sciolla
c4627cc882
Custom file upload MIME type (#927)
* Support curl-like syntax for custom MIME type for files

In order to specify a custom MIME type for file uploads, a syntax
similar to that used by cURL is used so that

http -F test_file@/path/to/file.bin;type=application/zip https://...

forwards the user-provided file type if provided, otherwise falling
back to the usual guesswork out of the file extension.
2020-06-08 17:59:41 +02:00
Jakub Roztocil
c2a0cef76e Add --format-options to allow disabling sorting, etc.
#128
2020-05-27 16:01:17 +02:00
Jakub Roztocil
493e98c833 Update CHANGELOG 2020-05-26 10:15:33 +02:00
Jakub Roztocil
d62d6a77d1 Add support for --ciphers (#870) 2020-05-23 13:26:06 +02:00
Jakub Roztocil
0c47094109
Update CHANGELOG.rst 2020-05-22 12:38:42 +02:00
Jakub Roztocil
defe4bc76d Fix issue links 2020-05-21 16:03:40 +02:00
Jakub Roztocil
afee6a7970 Added changelog entry for $XDG_CONFIG_HOME support 2020-05-21 15:59:03 +02:00
Jakob Krigovsky
e83e275dff
Fix spelling of “GitHub” (#899) 2020-04-20 17:45:51 +02:00
Jakub Roztocil
4a99495466
Update CHANGELOG.rst 2020-04-18 20:44:40 +02:00
Jakub Roztocil
774ff148cd 2.2.0-dev 2020-04-18 12:57:56 +02:00
Jakub Roztocil
70a78249c1 2.1.0
#488 #840 #895
2020-04-18 12:54:40 +02:00
Jakub Roztocil
cdf691c212
Change default JSON Accept to application/json, */*;q=0.5
Close #488
2020-04-13 22:12:06 +02:00
Jakub Roztocil
684a4708d7 Add --path-as-is
Close #895
2020-04-13 20:18:56 +02:00
Jakub Roztocil
e6bad645ed Fixed --form file upload mixed with redirected stdin error handling.
Close #840
2020-01-23 15:55:00 +01:00
Jakub Roztocil
deee2dffd0
Update CHANGELOG.rst 2020-01-13 14:50:58 +01:00