1712 Commits

Author SHA1 Message Date
Jan Verbeek
f7be3e2dab Mention RUST_LOG=trace in --debug help text 2024-06-20 22:19:03 +02:00
Jan Verbeek
7af8f9e94a Add timestamp to logs 2024-06-20 19:20:21 +02:00
Jan Verbeek
ea8cf23ab1 Warn for ;filename= tag on single-file body
Rust started linting this as dead_code.
2024-06-19 12:54:25 +02:00
Jan Verbeek
1792bf3ab6 Use log for application-level warnings and errors 2024-06-19 12:30:32 +02:00
Jan Verbeek
2823f62d03 Do not ignore empty-but-set RUST_BACKTRACE
The old way makes more sense to me but this is what Rust itself does.
2024-06-18 22:46:47 +02:00
Mohamed Daahir
ca629c803f remove unused file_name_header field from Body::File 2024-06-17 23:46:48 +01:00
Mohamed Daahir
78413036f0
Merge pull request #372 from blyxxyz/unconditional-tls-opts
Apply TLS options even for non-HTTPS URLs
2024-06-08 21:57:13 +01:00
Jan Verbeek
421e35dba0 Apply TLS options even for non-HTTPS URLs
TLS-related options were only being applied for URLs with a `https://`
scheme. But that's too cautious, because we could run into a HTTPS URL
after a redirect.

I've fixed this by just removing the check. Another option is to also
check `args.follow`, but I think it's nicer to do this stuff
unconditionally. That way we can consistently give errors for bad
options (e.g. `--verify=path/wiht/typo`).

Test case:
```shell
xh --verify=no --follow http://httpbin.org/redirect-to url==https://expired.badssl.com
```

Fixes #368.
2024-06-07 21:12:12 +02:00
Jan Verbeek
41ab47f32f Add --debug option for logging and backtraces
Add `env_logger` to be able to print the logs that our libraries
already generate.

Add some logging to the application code. We'll probably want more log
messages, and we might want to upgrade some of them from trace to
debug.

Add a `--debug` flag that automatically enables `env_logger` as well
as backtraces for `anyhow` and panics.

```console
$ xh --debug :
[2024-06-05T13:54:40Z DEBUG xh] xh 0.22.0 -native-tls +rustls
[2024-06-05T13:54:40Z DEBUG xh] Cli {
        httpie_compat_mode: false,
        [...]
    }
[2024-06-05T13:54:40Z DEBUG xh] Complete URL: http://localhost/
[2024-06-05T13:54:40Z DEBUG xh] HTTP method: GET
[2024-06-05T13:54:40Z DEBUG reqwest::connect] starting new connection: http://localhost/
[2024-06-05T13:54:40Z DEBUG hyper_util::client::legacy::connect::dns] resolving host="localhost"
[...]
xh: error: error sending request for url (http://localhost/)

Caused by:
    0: client error (Connect)
    1: tcp connect error: Connection refused (os error 111)
    2: Connection refused (os error 111)

Stack backtrace:
   0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.82/src/error.rs:565:25
[...]
```

We could ask users to post `--debug` output when reporting bugs.
2024-06-05 17:47:36 +02:00
Mohamed Daahir
0d873a00d9
Merge pull request #370 from blyxxyz/ignore-empty-no-color
Ignore `NO_COLOR` if set to empty string
2024-06-04 21:02:09 +01:00
Jan Verbeek
759a339f68 Ignore NO_COLOR if set to empty string
Environment variables can have no value at all or they can have the
empty string as a value. We used to disable color if `$NO_COLOR` were
set at all, regardless of its value, but as of
99f90e27d0
we should ignore empty strings (and this makes more sense).

Result: `NO_COLOR= xh` now allows colors.
2024-06-04 18:23:11 +02:00
Mohamed Daahir
61c0154476
Merge pull request #369 from bryanhonof/bryanhonof.add-flox
Add Flox as an installation method
2024-05-25 19:00:21 +01:00
Bryan Honof
db8d958fe2
Add Flox as an installation method 2024-05-24 14:39:41 +02:00
Mohamed Daahir
f3c05e00e3
Merge pull request #364 from zuisong/zstd
support zstd formatted responses
2024-05-18 20:14:37 +01:00
Mohamed Daahir
2d9c23eca2
Merge pull request #367 from huajingyun01/master
Update Cargo.lock
2024-05-18 15:26:34 +01:00
Jingyun Hua
65f726001a Update Cargo.lock 2024-05-16 01:53:31 +00:00
zuisong
94f0d6214f
use ruzstd crate 2024-05-06 10:38:39 +08:00
zuisong
c94fea2013
decode responses in zstd format 2024-05-06 10:38:39 +08:00
Mohamed Daahir
bdc026e883 fix clippy error 2024-05-04 12:26:44 +01:00
Mohamed Daahir
f1fc80a6cb
Merge pull request #365 from sorairolake/remove-get-version-action
Remove `battila7/get-version-action`
2024-04-29 05:05:50 +01:00
Shun Sakai
c8008582ad
Apply suggestion
Co-authored-by: Mohamed Daahir <sharaf.13@hotmail.com>
2024-04-29 10:45:58 +09:00
Mohamed Daahir
755e9298c4
Merge pull request #366 from ducaale/explicit-macos-version
Replace `macos-latest` with `macos-13`
2024-04-28 23:37:57 +01:00
Mohamed Daahir
adf4a2ea70 disable endpoints that randomly timeout 2024-04-28 23:33:58 +01:00
Mohamed Daahir
cf34e85e71 replace macos-latest with macos-13
`macos-latest` is now an alias for `macos-14` which runs on apple silicon
2024-04-28 23:20:15 +01:00
Shun Sakai
c48eca1f6a
Remove battila7/get-version-action 2024-04-23 12:56:51 +09:00
Mohamed Daahir
0c335ac26a bump version to v0.22.0 v0.22.0 2024-04-13 01:34:00 +03:00
Mohamed Daahir
57779c04aa raise msrv to 1.74 2024-04-13 01:21:28 +03:00
Mohamed Daahir
a42c386c6d update cargo lock file 2024-04-13 01:12:26 +03:00
Mohamed Daahir
bd893799a6 update README.md 2024-04-13 01:00:41 +03:00
Mohamed Daahir
52f534b45b update CHANGELOG.md 2024-04-13 00:54:07 +03:00
Mohamed Daahir
d788b99548
Merge pull request #363 from ducaale/no-stream
Use `--no-stream` to disable response streaming
2024-04-13 00:27:24 +03:00
Mohamed Daahir
e23940ddea update manpages and completions 2024-04-13 00:24:38 +03:00
Mohamed Daahir
40a0448918
Merge pull request #359 from ducaale/interface-name-bind
Directly bind to interface name on supported platforms
2024-04-13 00:19:04 +03:00
Mohamed Daahir
14af5b24db
Merge pull request #362 from blyxxyz/optimize-serde-json
Use serde-transcode to optimize JSON formatting
2024-04-12 23:32:06 +03:00
Mohamed Daahir
e9f62da7bc re-add comment about auto-disabling network-interface 2024-04-12 23:22:14 +03:00
Mohamed Daahir
9de67a0c60 use no-stream to disable streaming 2024-04-12 22:40:17 +03:00
Jan Verbeek
034591e2b7 Use serde-transcode to optimize JSON formatting
Instead of parsing the JSON input into a complicated heap value before
writing it out we can write it out as we parse it. On a ridiculously
large input this gives me a 5× speedup.
2024-04-12 21:18:10 +02:00
Jan Verbeek
398d567380 Make compressed reads interrupt-safe
A read operation might get an "interrupted" error, in which case the
correct behavior is (usually) to try again as if nothing happened.

When we read a compressed stream we check whether the underlying
reader received an error. But we should only check whether it received
an error for the latest read, so that we can ignore these interrupts
properly.

This is the only place I noticed where interrupts were handled
improperly.

AFAIK this can't happen in reality because we don't install signal
handlers, but it's good practice.
2024-04-12 20:51:52 +02:00
Mohamed Daahir
4fd1d9d9be
Merge pull request #361 from zuisong/serde_json_formatter
use serde_json format full json
2024-04-12 21:37:40 +03:00
zuisong
0957fa36e8
use serde_json format full json 2024-04-11 20:50:24 +08:00
Mohamed Daahir
269941e51c
Merge pull request #360 from zuisong/auto-enable-stream
enable stream when content-type is text/event-stream
2024-04-11 15:48:29 +03:00
zuisong
3c985f03f7
Apply suggested changes 2024-04-11 11:12:02 +08:00
zuisong
38724cc167
enable stream when content-type is text/event-stream 2024-04-07 17:52:08 +08:00
Mohamed Daahir
e25815bc1e Merge branch 'master' into interface-name-bind 2024-04-06 16:28:52 +01:00
Mohamed Daahir
4dc5588469
Merge pull request #357 from zuisong/upgrade-hyper
hyper v1 upgrade
2024-04-05 17:47:41 +01:00
zuisong
3f658ed4ed
hyper v1 upgrade 2024-04-06 00:40:21 +08:00
Mohamed Daahir
30b88308cb include network-interface in default features 2024-04-02 03:59:44 +01:00
Mohamed Daahir
5323433901 fix failing tests 2024-04-01 23:07:39 +01:00
Mohamed Daahir
3fa051a6db Merge branch 'master' into interface-name-bind 2024-04-01 23:05:40 +01:00
Mohamed Daahir
83da60e76e don't pull network-interface if platform supports SO_BINDTODEVICE 2024-04-01 23:03:46 +01:00