Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run the HTTP request without using CURL

Tags:

curl

busybox

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

like image 554
irom Avatar asked Oct 05 '15 17:10

irom


People also ask

Does HTTP use curl?

DESCRIPTION. curl is a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, GOPHER, DICT, TELNET, LDAP or FILE).

What is difference between curl and HTTP?

Curl is bundled with PHP, HTTPRequest is a separate PECL extension. As such, it's much more likely that CURL will be installed on your target platform, which is pretty much the deciding factor for most projects.

Do POST requests use curl?

When the -F option is used, curl sends the data using the multipart/form-data Content-Type. Another way to make a POST request is to use the -d option. This causes curl to send the data using the application/x-www-form-urlencoded Content-Type.

What HTTP method does curl use?

curl knows the HTTP method If you just pass in a HTTP URL like curl http://example.com , curl will use GET. If you use -d or -F curl will use POST, -I will cause a HEAD and -T will make it a PUT.


1 Answers

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.

like image 104
SergA Avatar answered Oct 08 '22 22:10

SergA