This is a starting point for JavaScript solutions to the "Build Your Own HTTP server" Challenge.
HTTP is the protocol that powers the web. In this challenge, you'll build a HTTP/1.1 server that is capable of serving multiple clients.
Along the way you'll learn about TCP servers, HTTP request syntax, and more.
- Ensure you have
node (18)
installed locally - Run
./your_server.sh
to run your program, which is implemented inapp/main.js
. - Start sending requests to your server using for example
curl
.
There are 5 routes, 4 of them are GET and one is a POST route.
GET: /
return 200.GET: /echo/<string>
return 200, content-length, and the passed string as the response body.GET: /user-agent
return 200, parse the user-agent from the request headers and return it as a response body.GET: /files/<file-name>
return 200, the content of the passed file if exists, if not it return 404.POST: /files/<file-name>
return 200, create a file with the provided name and the content of it grabs it from the request body.