265 Commits

Author SHA1 Message Date
Mohamed Daahir
7db9b3881d Merge branch 'master' into http-over-unix-socket 2025-01-19 15:21:51 +00:00
Stefan Zwanenburg
9ae2e3bfd4 Save cookie default-path if no explicit path attribute is present in Set-Cookie
Note that this commit does not alter the storage format of sessions.
Perhaps requiring a cookie path at all times would be a good idea, but
I haven't done that here, because I don't want to break existing
sessions for users.

Fixes: #400
2025-01-19 13:25:08 +01:00
Mohamed Daahir
92df488c3a revert disabling badssl tests 2025-01-11 10:27:59 +02:00
Mohamed Daahir
8bcbb0da90 disable failing badssl.com tests 2025-01-07 12:45:44 +02:00
Mohamed Daahir
de521084cd Merge branch 'master' into http-over-unix-socket 2024-12-30 17:01:46 +02:00
Mohamed Daahir
b6d59d9f9d avoid mocking host header 2024-12-30 11:23:17 +02:00
Jan Verbeek
6c2981c4c5 Move --download test cases to own file 2024-12-19 06:36:49 +01:00
Jan Verbeek
65ca2f0848 Merge remote-tracking branch 'origin/master' into smart-header-decode 2024-09-30 21:46:49 +02:00
Mohamed Daahir
89e5428618 Merge branch 'hotfix/v0.22.0-re-fix-download-path-escape' 2024-07-08 23:30:41 +01:00
Jan Verbeek
841f9c2e21 Prevent directory traversal in server-supplied filenames
If the `Content-Disposition` header includes directory
separators (e.g. `/`) then we now only take the base
filename. Including the directories is a vulnerability.

Originally fixed in 028cbb0165af54123a4829162a6a00f46e8dce74 but then
broken again in 330d3f2ed4e1af82ef89fefce2e6e84a8ac66330. This time I
added a regression test.
2024-07-08 07:46:55 +02:00
Jan Verbeek
00bc6f2238 Decode headers as latin1/UTF-8, show real reason phrase
External changes:

- We now print the actual reason phrase sent by the server instead
  of guessing it from the status code. That is, if servers reply with
  "200 Wonderful" instead of "200 OK" then we show that. This is
  especially useful for status codes that xh doesn't recognize.

- Header values are now decoded as latin1, with the UTF-8 decoding
  also shown if applicable.

- A new FAQ file with an entry that explains header value encoding.
  Header output now hyperlinks to this entry when relevant and if
  supported by the terminal.

Under the hood we now color headers manually. It's still hooked up to
the `.tmTheme` files but not to the `.sublime-syntax` file. This lets
us highlight the latin1 header values differently. In the future we
could use the same approach to optimize JSON highlighting.

I'm unsure about the position of the hyperlink. Currently it's the
text "UTF-8" in `<latin1 value> (UTF-8: <utf-8 value>)`. But that
means it's only shown if the value can be decoded as UTF-8. An
alternative is to turn the latin1 value itself into a hyperlink, but
that's confusing if the value itself is already a URL (which is a
common case for the `Location` header).

I also don't feel that our text is quite distinct enough from the
header value in the default `ansi` theme. Though the hyperlink does
help to set it apart.
2024-07-04 21:34:52 +02:00
Jan Verbeek
33e40527b7 Merge remote-tracking branch 'origin/master' into logging 2024-06-22 18:07:58 +02:00
zuisong
6c80a49353
apply suggestion 2024-06-22 09:40:30 +08:00
zuisong
3f24597737
decode CONTENT_DISPOSITION header value with utf-8
download file support unicode file name
2024-06-22 00:14:27 +08:00
zuisong
cb44ff5e8a
add test case 2024-06-21 23:32:54 +08:00
Jan Verbeek
10c309f88f Add test for ignored ;filename= tag 2024-06-20 23:14:18 +02:00
Jan Verbeek
d380228f87 Move logging-related tests to own file 2024-06-20 22:54:52 +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
zuisong
c94fea2013
decode responses in zstd format 2024-05-06 10:38:39 +08:00
Mohamed Daahir
adf4a2ea70 disable endpoints that randomly timeout 2024-04-28 23:33:58 +01:00
zuisong
0957fa36e8
use serde_json format full json 2024-04-11 20:50:24 +08:00
zuisong
3f658ed4ed
hyper v1 upgrade 2024-04-06 00:40:21 +08:00
zuisong
4a0ad40d4a
update http2-prior-knowledge test case
modify test cases so that it can be run offline
2024-03-25 14:25:13 +08:00
Mohamed Daahir
dc60a57fc3
Merge pull request #356 from zuisong/http2_prior_knowledge
support http2-prior-knowledge
2024-03-23 14:55:50 +00:00
Mohamed Daahir
13bb6c2082 Fix clippy warnings on Rust 1.77 2024-03-23 14:45:00 +00:00
zuisong
c60ced6708
support http2-prior-knowledge 2024-03-22 12:49:19 +08:00
zuisong
95da9bdf6f
display remote address in metadata 2024-01-17 20:45:21 +08:00
Mohamed Daahir
752af63284
Merge pull request #345 from jayvdb/fix-spelling
Fix typos
2024-01-16 07:47:39 +00:00
John Vandenberg
789178828e Fix typos 2024-01-15 18:54:58 +08:00
Mohamed Daahir
f6d2e56011 check host header when overriding dns resolution 2023-11-11 17:56:43 +00:00
Mohamed Daahir
9d9b44310f add test for --resolve flag 2023-10-08 17:06:16 +01:00
Mohamed Daahir
bc0062302a add e2e test for format options merging behaviour 2023-10-08 16:06:35 +01:00
Mohamed Daahir
f94af3abea Merge branch 'master' into format-options-part-2 2023-09-10 21:59:41 +01:00
Mohamed Daahir
24969862ea test session cookies from multiple domain 2023-08-05 10:11:46 +01:00
Mohamed Daahir
f6c6267f23 testing migration of old cookie format 2023-08-05 10:11:46 +01:00
Mohamed Daahir
89a4659e37 fix failing tests 2023-08-05 10:11:46 +01:00
Mohamed Daahir
00730816f5 revert defaulting to request host for domain 2023-08-05 10:10:16 +01:00
Mohamed Daahir
368bcf92ed enable cookie_store's preserve_order feature 2023-08-05 10:10:16 +01:00
Mohamed Daahir
eed5d43630 default to request host if cookie domain missing 2023-08-05 10:10:16 +01:00
Mohamed Daahir
156cf03652 fix existing tests 2023-08-05 10:10:16 +01:00
Mohamed Daahir
84ac980a48 add tests 2023-07-30 14:07:06 +01:00
Mohamed Daahir
c1df609723 update existing tests to use newer session format 2023-06-10 14:43:35 +01:00
Mohamed Daahir
218b0a51a0 remove unreachable code paths 2023-06-10 14:43:35 +01:00
Mohamed Daahir
34b5aa886f fix clippy error 2023-06-10 14:43:35 +01:00
Mohamed Daahir
e0ee8d0b64 add tests 2023-06-10 14:43:35 +01:00
Mohamed Daahir
2f7ddfb27a keyname 2023-06-10 14:43:35 +01:00
Mohamed Daahir
694c395cb0 update failing tests 2023-06-10 14:43:35 +01:00
Mohamed Daahir
12f861a2c6 replace httpbin with httpbin-go
Hopefully, this one will not randomly time out
2023-05-17 21:19:50 +01:00
Mohamed Daahir
0a62a6b4d3 remove tests related to https ip support 2023-04-09 16:02:39 +01:00
Mohamed Daahir
1fce2677af move --raw ∪ (k=v) logic to process_relations
This frees us from duplicating the logic inside to_curl.rs
2023-03-20 22:27:39 +00:00