There is a different way, without curl or other curl-like programs, without Python, Go, etc. It is smaller and faster, IME as a non-developer.
post api.ctl.io/v2/authentication/login < 1.txt|openssl s_client -connect api.ctl.io:443 -ign_eof
post is a 702-character shell script. printf is a built-in.
#!/bin/sh
(
y=Connection;n=0;while read x;do
x1=${1#*//};x2=${x1%%/*};x3=${x1#*/};
x=$(printf "%s" "${x%%:*}:";echo "${x#*:}");
if test x"${x3}" = x"${x2}";then x3="";fi;
printf "%s\r\n%s\r\n%s\r\n%s\r\n" \
"POST /${x3} HTTP/1.1" \
"Host: ${x2}" \
"Content-Type: application/json" \
"Content-Length: ${#x}";
if [ $n -gt 1 ];then
printf "%s\r\n\r\n%s\r\n" "$y: keep-alive" "$x";else
printf "%s\r\n\r\n%s\r\n" "$y: close" "$x";fi;
export n=$((n+1));
done;
if [ $n -gt 1 ];then
printf "%s\r\n%s\r\n%s\r\n" \
"GET /robots.txt HTTP/1.0" \
"Host: ${x2}" \
"$y: close";fi;
)
Data to be posted may be stored in a one-line file named "1.txt"
cat > 1.txt
{ "username": "YOUR.USERNAME", "password": "YOUR.PASSWORD" }
^D
Examine the request
post api.ctl.io/v2/authentication/login < 1.txt
POST the request
post api.ctl.io/v2/authentication/login < 1.txt|nc -vvn 127.1 80
Alternatively, data to be posted can be read from stdin
echo '{ "username": "YOUR.USERNAME", "password": "YOUR.PASSWORD" }' \
|post api.ctl.io/v2/authentication/login \
|nc -vvn 127.1 80
If the data to be posted is JSON formatted as multiple lines such as
{
"username": "YOUR.USERNAME",
"password": "YOUR.PASSWORD"
}
then something like
(tr -d '\12' < 1.txt;echo) \
|post api.ctl.io/v2/authentication/login \
|nc -vvn 127.1 80
For TLS we use proxy listening on 127.0.0.1, e.g., stunnel, sslsplit, haproxy, etc. This way we only ever have to type a single address and port, i.e., 127.1 80, or short alias for the hostname, e.g., echo 127.0.0.1 p >> /etc/hosts.
cat > 1.cfg
pid=/tmp/1.pid
[ x ]
accept=127.0.0.1:80
client=yes
connect=64.15.182.200:443
options=NO_TICKET
options=NO_RENEGOTIATION
renegotiation=no
sni=
sslVersion=TLSv1.3
^D
stunnel 1.cfg