Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl: show headers in bold #2538

Closed
wants to merge 2 commits into from
Closed

curl: show headers in bold #2538

wants to merge 2 commits into from

Conversation

bagder
Copy link
Member

@bagder bagder commented Apr 27, 2018

The feature is only enabled if the output is believed to be a tty.

-J: There's some minor differences and improvements in -J handling, as
now J should work with -i and it actually creates a file first using the
initial name and then renames that to the one found in
Content-Disposition (if any).

-i: only shows headers for HTTP transfers now (as documented).
Previously it would also show for pieces of the transfer that were HTTP
(for example when doing FTP over a HTTP proxy).

-i: now shows trailers as well. Previously they were not shown at all.

--libcurl: the CURLOPT_HEADER is no longer set, as the header output is
now done in the header callback.

@bagder bagder added cmdline tool feature-window A merge of this requires an open feature window on-hold labels Apr 27, 2018
@bagder
Copy link
Member Author

bagder commented Apr 27, 2018

Sample look: image

@jay
Copy link
Member

jay commented Apr 27, 2018

The windows console doesn't treat ansi escape codes as special, and as far as I know bold isn't possible

You will probably need to do something like this
#ifdef WIN32
#define BOLD_ON
#else
#define BOLD_ON "\x1b[1m"
#endif
and same for bold off

@bagder
Copy link
Member Author

bagder commented Apr 28, 2018

The windows console doesn't treat ansi escape codes as special

The question is perhaps if there's a chance the curl executable might be used in a terminal/console on windows that supports them? If so, that might require us to toggle this feature on/off depending on the terminal type in use...

@BobVul
Copy link

BobVul commented Apr 30, 2018

The windows console doesn't treat ansi escape codes as special

Technically, it does support the bold escape sequence in the most recent versions. Except conhost renders it as the bright version of the current colour, not bold.

In a completely default cmd-in-conhost window, this means bold is bright white and normal (default) text is (dim) white, so you do still benefit from the colour difference. In a default powershell-in-conhost window, normal (default) text is already bright white and setting 'bold' makes no difference.

This would also depend on the curl executable setting the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag (it's not passed along by built-in shells, i.e. cmd & powershell).

@bagder
Copy link
Member Author

bagder commented May 14, 2018

Rebased and now disabled on Windows.

@bagder bagder removed feature-window A merge of this requires an open feature window on-hold labels May 17, 2018
@bagder bagder changed the title curl: show headers in bold (WIP) curl: show headers in bold May 17, 2018
The feature is only enabled if the output is believed to be a tty.

-J: There's some minor differences and improvements in -J handling, as
now J should work with -i and it actually creates a file first using the
initial name and then *renames* that to the one found in
Content-Disposition (if any).

-i: only shows headers for HTTP transfers now (as documented).
Previously it would also show for pieces of the transfer that were HTTP
(for example when doing FTP over a HTTP proxy).

-i: now shows trailers as well. Previously they were not shown at all.

--libcurl: the CURLOPT_HEADER is no longer set, as the header output is
now done in the header callback.
It is enabled by default, so --no-styled-output will switch off the
detection/use of bold headers.
@bagder bagder closed this in f3d836b May 21, 2018
@bagder bagder deleted the bagder/bold-headers branch May 21, 2018 21:13
@jindraj
Copy link

jindraj commented Jul 11, 2018

There's different behaviour for
curl --styled-output -D - url
and
curl --styled-output -I url
While -I shows headers in bold, -D - doesn't.
Is that expected behaviour?

@bagder
Copy link
Member Author

bagder commented Jul 11, 2018

It is expected since I only enabled it for -I and -i. But I believe it should be possible to add for "-D -" too...

@jindraj
Copy link

jindraj commented Jul 12, 2018

I never used -i, but it's almost the same as -D -.

curl -i example.com prints even HTML in bold. At least for me. I have curl 7.61.0 installed from brew on macOS.

@bagder
Copy link
Member Author

bagder commented Jul 12, 2018

See #2736 and #2738

@xvybihal
Copy link

xvybihal commented Jul 13, 2018

From left to right: LilyTerm, Termit, Gnome Terminal, Terminator.

https://i.imgur.com/EFD1XJW.png

@bagder
Copy link
Member Author

bagder commented Jul 14, 2018

@xvybihal but how does the fix in #2738 work on those?

@lock lock bot locked as resolved and limited conversation to collaborators Oct 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

5 participants