Decode headers as latin1/UTF-8, show real reason phrase #377
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. (Resolves IRI output #323.)
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 theLocation
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?