Git Product home page Git Product logo

webserv's Introduction

WEBSERV

The aim of this project is to create a simple HTTP server.

Contributors to this project are:

Current Workflow

Technically non-existent. But,

JJ

Configuration Taking some referernce from NGINX configuration format, parse information necessary to create a minimum viable webserver. Information here will be required to run the server and send response back to browser.

  • Reading from .conf file
  • Scan word by word for keywords to be further process
  • Keyword/format supported are as follows
server 			//server keyword to parse a server block
{ 				//Start of a server block
	listen 80 81 82 83; 	//listen keyword to parse first non occupied port
	root html;				//root keyword to parse the path to root folder of webserver
	index index.html;		//index keyword to parse the index page of server
	server_name trinity.com;	//server_name keyword to parse the name of website
	
	error_pages 404 html/404.html; //error_page keyword to parse error number and path to error page html
	error_pages 405 html/405.html;

	location /cgi-bin { //location keyword to parse URI of website
		allowedMethods   GET POST; //allowedMethods keyword to parse the permitted method of a request
		index select_cgi.html; //index keyword to parse the index page of location URI, root + URI + index
	}
	
	location /directory {
		allowedMethods   GET;
		autoindex on;
	}
}		//End of a server block
//Any keyword not supported will result in exception being thrown

CGI Execution A simple CGI execution function is also written to run scripts/executable in child process and response will be return.

Hong You

The part I worked on deals with the main handler loop of the server. This covers the following:

Initialisation

  • Creating the socket
  • Binding the socket to the port
  • Listening for incoming connections
  • Accepting connections
  • Closing connections

Connections

  • Reading from the socket(s)
  • Writing to the socket(s)
  • Closing connections with the socket(s)

I have also helped with the integration of the configuration parser and the request parser into the server.

Mars

My job is to handle request parsing, method handling and responses. Here's what I deal with:

  • Dividing the request into the header and body
  • For all methods I must validate the resource path and validate method permissions.
  • GET simply covers locating the required resource, opening and reading the file, and then returning the contents as the response.
  • POST:
    • The types of data sent through POST is limited to application/x-www-form-urlencoded and multipart/form-data
    • The data to be stored must be validated; if it exists, send a 409 Conflict.
    • Else, store the data and return a 201 Created.
    • For application/x-www-form-urlencoded:
      • The data sent through will be encoded.
      • Therefore in order to store the data completely, it has to be decoded.
  • DELETE:
    • We chose to only test DELETE from command line. (To save time)
    • The data stored is validated, deleted, and return a response 200 OK :thumbs_up:

References

Web Server Concepts and Examples

C++ Web Server from Scratch

cclaude's 42 Webserv Github Page

Disclaimer: Please don't copy another persons work. Cclaude's page includes a very detailed Readme page with very helpful resources that we used as references.

HTTP related RFCs

webserv's People

Contributors

m4rrs avatar thewongwaae avatar skyhearts avatar

Watchers

 avatar

Forkers

skyhearts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.