Solved–Assignment 8 –Solution

$30.00 $19.00

/ Instructions This is an optional assignment. It is 100% extra credit and worth 1 full assignment of points. Download the template Java program in Canvas: Files/WebServer.zip Please compress your code and README.txt file into a zip file or tar.gz. / Programming Assignment As is, the server will compile and listen on port 8080. It…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

/ Instructions

This is an optional assignment. It is 100% extra credit and worth 1 full assignment of points.

Download the template Java program in Canvas: Files/WebServer.zip

Please compress your code and README.txt file into a zip file or tar.gz.

/ Programming Assignment

As is, the server will compile and listen on port 8080. It can be accessed by:

http://127.0.0.1:8080/

Currently, it will print the HTTP request header to the console window and simply send back “Hello World!” (with no HTTP response header). I tested this with Firefox and Edge and it works well with both.

You need to implement a web server which has the following functionality:

  • You need to implement HTTP 1.1 handling for GET and HEAD requestes

  • You need to figure out how to respond with HTTP 1.1 response headers

  • The server should treat the “webroot” subdirectory as the root directory for the web server… in other words, http://127.0.0.1:8080/ should point to the “webroot” directory

  • If a directory is the target and there is no file specified

  1. the web server should look for a file named “index.html”, if that file exists, then return that object

    1. if there is no “index.html” file then your server needs to render a HTML page which creates clickable links for the subdirectories and files. For example:

..” which should point to the parent directory

      • Clicking on a file should load it in the browser (in other words, make sure to render the filename as a link to the URL of the file)

  • You should return different MIME types in the HTTP response header for different files (based on file extension). You need to at least handle TEXT and HTML

  • Tips

    • Start early!

    • Ask questions… ask them in the discussion on Canvas first before asking me.

    • Help other students!

    • The IP address of your server is 127.0.0.1

    • The port of your server is 8080

    • I have provided you a basic Makefile… this makes things simpler when compiling your program

    • Pay attention to things like MIME types in the HTTP header – the browser will render content differently for different types

  • Additional Things You Could Do

Please note, these won’t garner you any extra credit, and are not required. However, they are things which may interest you (and will certainly teach you a lot about HTTP).

    • Handle images (and their corresponding MIME types)

    • Handle JSON (and MIME type)

    • Create / interface with a scripting library (like PHP)

    • Figure out how to handle POST (especially for file uploads)

  • Useful Links