, , , , , , ,

[SOLVED] CSC324 PROGRAMMING ASSIGNMENT 2 HTTP-based web server

30 $

File Name: CSC324_PROGRAMMING_ASSIGNMENT_2_HTTP-based_web_server.zip
File Size: 499.26 KB

Categories: , , , , , , , Tags: , , , , , , ,

Or Upload Your Assignment Here:


To create a HTTP-based web server that handles multiple simultaneous requests from users.
Foreword –
Please take time to thoroughly read and understand the document. Only concepts, directions and
objectives will be provided in this document. The assignment will teach you the basics of network
programming, client/server communication message structures, and will provide a step toward building
high performance servers. You must work individually on this assignment; we will check for plagiarism.
Background –
What is a web-server?
A web server is a program that receives requests from a client and sends the processed result back to the
client as a response to the command. A client is usually a user trying to access the server using a web
browser (Google Chrome, Firefox).
The HTTP request consists of three substrings – request method, request URL, and request version. All
three parts should be separated by one or more white spaces.
The request method should be capital letters like “GET”, “HEAD”, and “POST”.
The request URL is a set of words which are case insensitive and separated by “/” and the server should
treat the URL as a relative path of the current document root directory.
The request version follows the rule like “HTTP/x,y” where x and y are numbers.
Here is an example to make things clearer –
If you type an URL like http://www.w3.org/Protocols/rfc1945/rfc1945 in a web browser, the web browser
will send an HTTP GET command to the server http://www.w3.org/ after establishing a TCP connection
with port 80 on the server. In this scenario, the format for the HTTP GET command received at the web
server is as follows:
GET /Protocols/rfc1945/rfc1945 HTTP/1.1
Based on the rules, we can identify three substrings like the following:
Request Method: GET
Request URI: /Protocols/rfc1945/rfc1945
Request Version: HTTP/1.1
Deliverables in detail:
Your server should start without any arguments: ./webserver
Your server should be running in a Forever running loop once it has started. You are expected
to exit out of the server gracefully (Either finish all the pending requests, timeouts and then exit
or just exit out bluntly closing the listen socket properly though) when pressing the escape
sequence (Ctrl + C or any key(s) of your choice).
In this assignment, the Web server will have a document root which would contain files with the
extension “.html” “.htm”, “.txt”, “.jpg”, “.gif”. When the web-server receives a HTTP request from a client
(from a web-browser such as chrome) for a particular file, it should open the file from this document root
and then send the file back to the client with proper header information. Header information is the
required to be sent along with the file so the web-browser would understand that the HTTP request was
successful and the response is being received. In all cases, the names of files in the Request URL should
be interpreted in the context of the current document root. If the server interprets the request (HTTP
GET) and the requested file exists on the specified location, the server needs to send both Content-Type
and Content-Length followed by an appropriate status code. The file content should be separated by a
carriage-return-line-feed (“
”) from the header. For example, when the client requests an existing
“.html” file on the server, such a file exists in my server, so server replies with a 200 status code.
The Status Code “200” indicates that the requested file exists and the server is going to send the
processed data (the requested file) back to the client. The string next to Status Code “200” conveys the
information that the requested document that will follow in this reply. Usually, many Web servers use
“Document Follows” and “Ok” for that field.
Sample Header Format-
HTTP/1.1 200 Document Follows
Content-Type: <> #Tells about the type of content and the formatting of
Content-Length: <> #Numeric length value of the no. of bytes of

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CSC324 PROGRAMMING ASSIGNMENT 2 HTTP-based web server
30 $