Feature Request: Automatically pass information about the terminal in HTTP headers
- Automatically pass information about the terminal in HTTP headers
It would be great (when some special key, something like -t) is specified, to pass information about the terminal (to which the client is attached) as HTTP-headers.
That means, that
http -t wttr.in
is equivalent to:
http wttr.in \
Accept-Language:${LANG%%_*} \
X-Terminal-Attached:$([ -t 1 ] && echo yes || echo no)
X-Terminal:${TERM} \
X-Terminal-Columns:${COLUMNS} \
X-Terminal-Lines:${LINES} \
Of course, the last three headers make sense only if terminal is attached.
Reason:
Services like wttr.in, cheat.sh, rate.sx use ANSI sequences
to colorize the output; but it makes no sense when the program
is not attached to the terminal; currently a special option
(?T) is used to switch the ANSI off, but it would be much
better if the client could pass this information
automatically.
Services like rate.sx could draw their plots not 80x25,
as they do currently, but they could rely on the terminal size
passed to them by the client.
[copying from our email conversation] This would be better served by a plugin. The API currently doesn’t support custom options but I will see if I can change the API for the upcoming v2.0 release.
I also agree that we should not be sending additional headers every time we send a request. The plugin approch seems to be the best way to go with this, but if we'd add this to the core then it should definitely be guarded with a flag.