How to run the HTTP request without using CURL

irom picture irom · Oct 5, 2015 · Viewed 38.6k times · Source

I have arm-based busybox (Embedded Linux) with limited binaries. How to http post or put without using curl?

Answer

SergA picture SergA · Oct 18, 2015

busybox has wget but this limited and unsuitable for posting. You can combine busybox with netcat (or nc) for achieving the result. You only need to download netcat binaries for your platform. And here we go:

POST_PATH="/login.cgi"
HOST=199.188.1.99
BODY="Put here HTML body...."
BODY_LEN=$( echo -n "${BODY}" | wc -c )
echo -ne "POST ${POST_PATH} HTTP/1.0\r\nHost: ${HOST}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ${BODY_LEN}\r\n\r\n${BODY}" | \
  nc -i 3 ${HOST} 80

Based on Sending HTTP POST request with netcat post.