Re:HN “Why Not Simply”
by 1vuio0pswjnm7 on Monday June 07, 2021 @03:47PM
(#27426669)
small correction
example usage:
sed -n '/{\"hits\":/p' 1.json|json_reformat|sed 's/ //;s/\\n/ /g'|less
also
instead of entering ^M, we can use something like djb's "addcr" from ucspi-tcp, a simple program that adds a carriage return ("\r") to each line
here is a simple shell version of addcr that also removes indention
x=$(echo x|tr x '\r');
exec sed "s/ *//;s/$/$x/";
example usage: stunnel -fd 0 <<eof1
pid=$HOME/1.pid
foreground=no
[ $$ ]
accept=127.0.0.21:80
client=yes
connect=graphql.example.com:443
sslVersion=TLSv1.3
eof1
addcr <<eof2|nc -vvn 127.21 80
POST /v1/api HTTP/1.1
Host: graphql.example.com
Connection: close
Content-Type: x-www-form-urlencoded
Content-Length: $((${#@}+141))
{"query":"$@"}
eof2
cd;kill $(cat 1.pid);**
text-only, no Javascript required, no SNI, unnecessary HTTP headers, DNS, etc.
json_reformat is from https://github.com/lloyd/yajl/
^M is Ctrl-v+Ctrl-m
example usage:
1.sh query > 1.json
json_reformat < 1.json|sed 's/ *//;s/\\n/ /g'|less