ducaale / xh

Friendly and fast tool for sending HTTP requests
MIT License
5.49k stars 96 forks source link

Decode headers as latin1/UTF-8, show real reason phrase #377

Closed blyxxyz closed 3 days ago

blyxxyz commented 3 months ago

image

External changes:

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.

We should use a stable URL that keeps working in the future. I linked to FAQ.md on this repo's master branch (https://github.com/ducaale/xh/blob/master/FAQ.md#header-value-encoding, won't work until it's merged) but maybe there's a better option?

blyxxyz commented 2 months ago

(Sorry for the big diff for such a small feature! I'm hoping it'll be useful for other things in the future.)

ducaale commented 1 week ago

Apologies for taking so long to review this 😬. I’ll make sure to leave a review by this weekend.