Giter Club home page Giter Club logo

http-web-server's Introduction

Java-Web-Server-HTTP-Requests HitCount GitHub license

This is an HTTP server implemented in Java using the native java.net and java.io libraries. It supports HTTP GET, HEAD and DELETE requests from multiple clients through threading, and responses appropriately to connecting clients using the 200 OK, 204 No Content, 404 Not Found and 501 Not Implemented codes. It also supports text files such as text/html and binary images such as images/jpg, images/jpeg, images/png and images/gif. The server logs every request to a .log file. This project was completed for the CS5001 module as a part of my MSc in Artificial Intelligence at the University of St Andrews.

A short report of the advanded requirements can be read here.

Installation

  1. Clone the project: git clone https://github.com/Adamouization/Java-Web-Server-HTTP-Requests

  2. Cd into the directory and compile the files, then run the source code:

cd Java-Web-Server-HTTP-Requests
javac src/*.java src/exception/*.java

Usage

Server

Run the server:

cd src/
java WebServerMain <document_root> <port_number> <max_number_of_active_threads>

where:

  • document_root is the root directory from which the server will serve documents.
  • port_number is the port on which the server will listen.
  • <max_number_of_active_threads> is the maximum number of clients that can connect simultaneously to the server.

Example: java WebServerMain ../www 12345 100

Run the tests (on University machines): stacscheck Tests/

Client

A testing web root directory with html and binary image files is provided in the www directory.

  • Terminal
    • GET request method
      • headers: curl -s -I -X GET localhost:12345/index.html
      • text content: curl -s -X GET localhost:12345/index.html
    • DELETE request method
      • headers: curl -s -I -X DELETE localhost:12345/delete_me.txt
      • content: curl -s -X DELETE localhost:12345/delete_me.txt
    • 404 Error: curl -s -X GET localhost:12345/test.html (File not found)
    • 501 Error: curl -X SLURP localhost:12345/index.html (POST not implemented)
  • Web browser
    • Default page (GET): open http://127.0.0.1:12345/
    • Binary image content: open http://127.0.0.1:12345/stars.gif

Javadocs

  1. Generate the Javadocs: javadoc -d javadoc src/*.java src/exception/*.java

  2. Open javadoc/index.html in your web browser.

Contact

http-web-server's People

Contributors

adamouization avatar

Watchers

 avatar  avatar  avatar

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.