Skip to content

a HTTP server that's capable of handling simple GET/POST requests, serving files and handling multiple concurrent connections.

Notifications You must be signed in to change notification settings

fdrissi/http-server-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

progress-banner

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.

How to

  1. Ensure you have node (18) installed locally
  2. Run ./your_server.sh to run your program, which is implemented in app/main.js.
  3. Start sending requests to your server using for example curl.

Routes

There are 5 routes, 4 of them are GET and one is a POST route.

  1. GET: / return 200.
  2. GET: /echo/<string> return 200, content-length, and the passed string as the response body.
  3. GET: /user-agent return 200, parse the user-agent from the request headers and return it as a response body.
  4. GET: /files/<file-name> return 200, the content of the passed file if exists, if not it return 404.
  5. POST: /files/<file-name> return 200, create a file with the provided name and the content of it grabs it from the request body.

About

a HTTP server that's capable of handling simple GET/POST requests, serving files and handling multiple concurrent connections.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published