Commit Graph

107 Commits

Author SHA1 Message Date
Jakub Roztocil
0689b55e1d
Clean up and refactor nested JSON parsing & interpreting (#1440) 2022-10-01 03:38:19 -07:00
Jakub Roztocil
418b12bbd6 Cleanup 2022-06-07 14:31:15 +02:00
Batuhan Taskaya
33ea977b64
Don't send Content-Length for OPTIONS requests when there is no data. (#1319) 2022-04-03 06:02:41 -07:00
Batuhan Taskaya
65ab7d5caa Implement new style cookies 2022-03-07 23:29:48 +03:00
Batuhan Taskaya
15013fd609 Implement support for private key passphrases 2022-03-07 16:09:07 +03:00
Batuhan Taskaya
225dccb218
Regulate top-level arrays (#1292)
* Redesign the starting path

* Do not cast `:=[1,2,3]` to a top-level array
2022-02-08 15:18:40 -08:00
Jakub Roztocil
c815e21ef9
Fix time elapsed (#1277)
* Show the actual time elapsed; add docs

* `requests.Response._headers_parsed_at` → `requests.Response._httpie_headers_parsed_at`

* Add `ELAPSED_TIME_LABEL` constant

* Tweak docs

* Tweak docs

* Allow multiple blank lines in Markdown files

* Add rudimentary tests for --meta with different --style’s

* Cleanup tests

* Cleanup tests

* Cleanup tests
2022-01-23 04:52:38 -08:00
Batuhan Taskaya
00c859c51d
Add warnings when there is no incoming data from stdin (#1256)
* Add warnings when there is no incoming data from stdin

* Pass os.environ as well

* Apply suggestions
2022-01-12 06:07:34 -08:00
Batuhan Taskaya
4c56d894ba
Fix --raw with --chunked (#1254)
* Fix --raw with --chunked

* Better naming / annotations

* More annotations
2021-12-29 12:41:44 +03:00
Batuhan Taskaya
df58ec683e
Add nested JSON syntax to the HTTPie DSL (#1224)
* Add support for nested JSON syntax (#1169)

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
Co-authored-by: Jakub Roztocil <jakub@roztocil.co>

* minor improvements

* unpack top level lists

* Write more docs

* doc style changes

* fix double quotes

Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
2021-12-03 02:17:45 -08:00
Batuhan Taskaya
245cede2c2
cmd: Implement httpie plugins interface (#1200) 2021-11-30 11:12:51 +03:00
Batuhan Taskaya
ef62fc11bf
core: support custom request/response classes (#1205)
* core: support custom request/response classes

* Move to `httpie.models`, prefix with `Requests`
2021-11-24 15:45:39 -08:00
Batuhan Taskaya
c000886546
Preserve individual headers with the same name on responses (#1208)
* Preserve individual headers with the same name on responses

* Rename RequestHeadersDict to HTTPHeadersDict

* Update tests/utils/http_server.py

* Update tests/utils/http_server.py

* Update httpie/adapters.py

Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
2021-11-24 15:41:37 -08:00
Batuhan Taskaya
7cdd74fece
Support multiple headers sharing the same name (#1190)
* Support multiple headers sharing the same name

* Apply suggestions

* Don't normalize HTTP header names

* apply visual suggestions

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

* bump down multidict to 4.7.0

Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
2021-10-31 15:04:39 +01:00
Mickaël Schoentgen
4f1c9441c5
Fix encoding error with non-prettified encoded responses (#1168)
* Fix encoding error with non-prettified encoded responses

Removed `--format-option response.as` an promote `--response-as`: using
the format option would be misleading as it is now also used by non-prettified
responses.

* Encoding refactoring

* split --response-as into --response-mime and --response-charset
* add support for Content-Type charset for requests printed to terminal
* add support charset detection for requests printed to terminal without a Content-Type charset
* etc.

* `test_unicode.py` → `test_encoding.py`

* Drop sequence length check

* Clean-up tests

* [skip ci] Tweaks

* Use the compatible release clause for `charset_normalizer` requirement

Cf. https://www.python.org/dev/peps/pep-0440/#version-specifiers

* Clean-up

* Partially revert d52a4833e4

* Changelog

* Tweak tests

* [skip ci] Better test name

* Cleanup tests and add request body charset detection

* More test suite cleanups

* Cleanup

* Fix code style in test

* Improve detect_encoding() docstring

* Uniformize pytest.mark.parametrize() calls

* [skip ci] Comment out TODOs (will be tackled in a specific PR)

Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
2021-10-06 17:27:07 +02:00
Jakub Roztocil
6633b5ae9b Use UTF8 constant in FORM_CONTENT_TYPE as well 2021-08-05 21:00:17 +02:00
Mickaël Schoentgen
c6cbc7dfa5
Uniformize UTF-8 naming (#1115)
* Uniformize UTF-8 naming

Replace `utf8` -> `utf-8` everywhere.
It should have no impact, `utf8` is an alias of `utf-8` [1].

[1] ee03bad25e/Lib/encodings/aliases.py (L534)

* Always specify the encoding

Let's be explicit over implicit. And prevent future warnings from PEP-597 [1].

[1] https://www.python.org/dev/peps/pep-0597/#using-the-default-encoding-is-a-common-mistake

* Update `UTF8` constant (`utf-8` -> `utf_8`)

* Remove default argument from `str.encode()` and `bytes.decode()`

* Clean-up
2021-08-05 20:58:43 +02:00
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
nixbytes
c8d70e8c0b
Simplify return statements in client.py (#1096)
Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
2021-06-28 09:05:24 +02:00
Mickaël Schoentgen
a3a08a9a22
Use relative imports (#1057)
* Use relative imports in test

* Use relative imports

* Add myself to contributors :)
2021-05-05 14:13:39 +02:00
Jakub Roztocil
2afdc958c6 Update URLs 2020-12-23 22:07:27 +01:00
Jakub Roztocil
2f8d330b57 Fix --offline --chunked, add more tests 2020-09-28 16:40:16 +02:00
Jakub Roztocil
32d8b481e9 Fix --offline --multipart, add more tests 2020-09-28 16:22:34 +02: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
b7754f92ce Merge branch 'master' into feature/uploads2020
# Conflicts:
#	httpie/cli/argparser.py
#	httpie/uploads.py
2020-09-25 14:46:19 +02:00
Jakub Roztocil
e4e40e5b06 Request content type 2020-09-25 14:44:22 +02:00
Jakub Roztocil
d12af4a569 WIP 2020-09-25 13:44:28 +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
37200eb055 Cleanup 2020-06-15 23:02:16 +02:00
Eyitayo Ogunbiyi
9c68d7dd87
Remove expired cookies (#929)
* added a test for expiring cookies

* updated tests

* set up util for extracting expired cookies from response header

* Revert "updated tests"

This reverts commit a4eb5c4498.

* Revert "Revert "updated tests""

This reverts commit d242e21bce.

* added more functionality to get-expired-cookies

* add 'clear expired cookies' from session.json files

* refactored get_expired_cookies

* fixed formatting issues

* ensured key exists in cookie_header dict

* fixed linting errors

* removed unused import

* Added tests for get_expired_cookies util

* Added additional test for get_expired_cookies

* added remove_expired_cookies method directly to sessions class

* extracted logic to clear cookies to sessions.py

* refactored utils

* added tests to check expired cookies being removed from session obj

* added type annotations for methods

* Refactored test_sessions

* Seperated out expiry related tests into own class

* Refactored get_expired_cookies in utils

* Refactored remove cookie methods

* fixed linting errors

* fixed indentation and also pluralized test class name

* removed inheritance from SessionTestbase class

* Moved related test to TestExpiredCookies class

Co-authored-by: kbanc <katherine.bancoft@gmail.com>
2020-06-15 22:28:04 +02:00
Jakub Roztocil
cd085cbc0d Refactor built-in plugin registry to avoid circular imports
Fix #925
2020-05-26 10:07:34 +02:00
Jakub Roztocil
27d57ce773 Cleanup 2020-05-23 20:30:25 +02:00
Jakub Roztocil
4c4efff56a Pass cert_reqs to context 2020-05-23 20:19:16 +02:00
Jakub Roztocil
d62d6a77d1 Add support for --ciphers (#870) 2020-05-23 13:26:06 +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
490eeaa650 Cleanup 2019-12-03 19:09:09 +01:00
Jakub Roztocil
f202f338a4 Remove automatic config file creation to avoid concurrency issues.
Close #788
Close #812
2019-12-02 17:43:16 +01:00
Jakub Roztocil
c8fd4c2d6e Move compression out of adapter 2019-09-04 00:00:03 +02:00
Jakub Roztocil
bece3c77bb Add one-by-one processing of each HTTP request or response and --offline 2019-09-03 17:14:39 +02:00
Jakub Roztocil
c946b3d34f Cleanup 2019-09-02 14:38:23 +02:00
Jakub Roztocil
45e8e4e4ea Sessions 2019-09-01 21:15:39 +02:00
Jakub Roztocil
4dffac7a25 Refactor client 2019-09-01 11:38:14 +02:00
Jakub Roztocil
9da5c41704 Improve --debug output formatting 2019-08-31 18:00:03 +02:00
Jakub Roztocil
224519e0e2 Fix --ssl with --compress; refactor client 2019-08-31 17:52:56 +02:00
Jakub Roztocil
aba3b1ec01 Refactoring 2019-08-31 15:17:10 +02:00
Jakub Roztocil
0f654388fc Python 3 annotations, super(), pathlib, etc. 2019-08-30 15:14:51 +02:00
Jakub Roztocil
a4d8f1f22e Refactor --compress tests 2019-08-29 11:46:08 +02:00
Aleksandr Vinokurov
5ec954c03d Add compressed requests (#739)
* Add optional compression of the request's content

This option allows compression of the files and/or data during uploading,

Examples:

    http --form --compress POST https://localhost/upload csv@./very-big.csv

    http -x -x POST https://localhost/upload foo=bar

    cat /var/log/system.log | http -x POST https://localhost/upload

Signed-off-by: Aleksandr Vinokurov <aleksandr.vin@gmail.com>

* Add tests for compression

Signed-off-by: Aleksandr Vinokurov <aleksandr.vin@gmail.com>

* Fix code style issues

Signed-off-by: Aleksandr Vinokurov <aleksandr.vin@gmail.com>

* Fix zlib compression api missuse in Python3

Signed-off-by: Aleksandr Vinokurov <aleksandr.vin@gmail.com>

* Remove tracing from compression logic

Signed-off-by: Aleksandr Vinokurov <aleksandr.vin@gmail.com>
2019-08-29 10:44:59 +02:00