Goal of the lab is to create an HTTP library using sockets. For this purpose, I have used the 'net' package from Node. Furthermore, we are required to create a CURL-like command-line application.
The code is in TypeScript, which is a superset of JavaScript. It runs on Node.js. Instructions on compiling are below, but a working build is currently in the build
folder.
- Clone the repo.
- Run
npm install
. - Run
tsc
to compile. - Run
npm link
. - Run
httpc help
.
httpc get "http://httpbin.org/get?assignment=1&tutor=john"
httpc get "http://httpbin.org/get?assignment=1&tutor=john" -v
httpc post http://httpbin.org/post -h Content-Type:application/json -d "{\"Assignment\": 1}"
httpc post http://httpbin.org/post -h Content-Type:application/json -f test.txt
httpc post http://httpbin.org/post -h Content-Type:application/json -f test.txt -v
httpc post http://httpbin.org/post -h Content-Type:application/json -f test.txt -v -o output.txt
httpc get "http://httpbin.org/redirect-to?url=http://httpbin.org/get?argument=1&status_code=302" -r -v