Challenge Attempt

  • Preferred language: Nodejs
  • Use node:net package for support of Sockets
  • Bind socket to the address of your server (127.0.0.1)
  • Basically we are creating a socket, reading data from it, writing data to it and closing it.
  • To return html file content, read HTML file manually and return the data of file from socket.
  • When making a curl request all of the data comes like this,
  • When it is not a valid path, return HTTP/1.1 400 Not Found
  • Now handle Concurrency so multiple requests/ clients can be addressed.
  • Traditionally this was handled by creating a new thread for each connection, more recently there has been a focus on using asynchronous frameworks, this boils down to there being an overhead to threads. If you’ve never used threads now would be a great time to try it out. If you have then perhaps try the async framework for your stack of choice. There’s an overview of parallelism, concurrency, and asynchrony on the Coding Challenges blog.
  • Common_Gateway_Interface can help to generate dynamic content for the webservers.

Questions

  • Q. Why are Sockets getting used for creating server? Do Express.js also do it in similar way?
  • Q. Is there any distinction between the header and the other content or everything comes as a blob/ text?
  • Q. So all these libraries decide by themselves what HTTP version they will be implementing? Like Express.js will just read the new HTTP specifications from w3.org and update its code to address those?
  • Q. What can be some of the security threats here? Is is prone toman_in_the_middle ,cross_site_scripting_XSS ,Cross_Site_Request_Forgery