portatlas / httpserver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP Server

This project is an implementation of a basic HTTP Server built with Java.

The HTTP Server supports the following:

  1. HTTP Methods: simple GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS.
  2. Decoding Parameters
  3. Basic Authentication
  4. Basic Cookie Implementation (Setting a cookie on the client side)
  5. The server can serve txt, jpeg, png, and gif files.
  6. Range request can be made to get partial content from a txt file

Getting Started

Clone this repository to your local machine
$ git clone https://github.com/portatlas/httpserver.git
$ cd httpserver

Dependencies

  1. Java 1.8
  2. JUnit 4.12
  3. Maven

Run Tests

Run the following command to run the unit tests:
$ mvn test

Run Acceptance Test

The acceptance test and instructions to run them can be found here

Compile and Build Package

At the root dir run the command:
$ mvn package

Run the Server

At the root directory run the command:
java -jar target/httpserver-1.0.jar -p 5000

Where:
-p is the port
-d is the resource directory (if a directory argument is not supplied the server will default to the public directory in the repo)

You should see the port and directory displayed to the console.

When a HTTP request is made to the server you should be able to see the response on the console.

Additionally, you can go to http://localhost:5000 on your browser and interact with the server there.

About


Languages

Language:Java 100.0%