Are you manually detecting Curl specifically? If I use anything other than Curl, e.g. HTTPie or wget, I get the HTML page, even if I provide an `Accept: text/plain` request header. If I use one of those tools and spoof the Curl user agent string, I get the text/plain response. You should probably just look at the Accept request header, it’s there specifically so clients can tell you what kind of response they want.
Great idea.
I just implement it: https://github.com/yeo/ec2.shop/commit/ab258aef3ac2ad3d45b26...
Now by default it's text mode, so request by http client library or tool like curl, wget, httppie all get text bersion.
Only when detecting `Accept` contains `html` and user agent is safari/chrome/firefox etc it send html version.
There should be no reason to check user agent if already checking `Accept`. That's usually more for browser quirks or allow/blocking.
There should be a new mime type for this: text/x-ansi
but why "ansi"? ANSI is only an encoding. You can have html that's in ansi, and you can have something like OP's that's not in ansi (eg. if you add emojis).
This is "ANSI" as in ANSI X3.64 escape sequences, not "ANSI" as in a character encoding. You can output color to curl on an ANSI-compatible terminal but not to something expecting actual plain text like a browser.
I think text/ecma48 would be a better name. There are lots of ANSI standards. (I guess text/ansi-x3.64 might also work, but text/ecma48 seems simpler.)
Yes, I should have been more specific. text/x-term-${TERM} probably would be better, since it could be any number of terminal types...
You might be thinking of ASCII?
From the wiki: "The phrase ANSI character set has no well-defined meaning and has been used to refer to the following, among other things"
So if you are thinking of CP-437 or Windows-1252 I suppose that's fair, but generally in the context of terminal apps "ANSI" without qualification refers to the escape sequences.
Now I am curious though, did ANSI the standards body have any official character encoding standards?
Useful tool!
Do you not need to escape the ampersand in the second example? otherwise bash will run it in the background and skip the `filters=t2,m4` part.
Yes, but many terminals will escape it for you if you paste in.
Re:Show HN: Curl https://ec2.shop
by brodouevencode on Tuesday June 30, 2020 @09:24AM
(#23689715)
And it has to be infinitely better than using the pricing API.
So I develop this small tool which you can do thing like