Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomiwa-ot/java-web-server

Simple HTTP server written in Java
https://github.com/tomiwa-ot/java-web-server

blocking-queue http-basic-auth http-server java maven multithreaded-server producer-consumer socket webserver

Last synced: about 22 hours ago
JSON representation

Simple HTTP server written in Java

Awesome Lists containing this project

README

        

## Java Web Server

A simple multithreaded HTTP server built with the Producer-Consumer design pattern and synchronised with blocking queues.

### Features
- Directory Listing
- Basic HTTP Authentication
- Logs all requests ```webserver.log```

### Configuration

#### Port
The default port used is 8080. It can be modified either by changing the port value in [properties.json](src/main/resources/properties.json) or supply it as an argument in the console.
```console
javac App.java
java App
```
#### Basic HTTP Authentication
To enable, change the username value from ```null``` to `````` and password value from ```null``` to a Bcrypt hash of the password in [properties.json](src/main/resources/properties.json)
```json
{
"username" : "your_username",
"password" : "Bcrypt hash",
}
```
To disable, set the username and password values as ```null```.

#### Worker Threads and Connection Queue
The number of consumer threads and blocking queue size can be modified in [properties.json](src/main/resources/properties.json)
```json
{
"worker_threads" : 20,
"connection_queue" : 30
}
```

#### Screenshots
![Index page](screenshots/screenshot01.png)
![Viewing a file](screenshots/screenshot02.jpg)
![BAsic HTTP authorization](screenshots/screenshot03.png)

### TODO
- Request for basic authentication if username & password are set
- Allow user to specify web root folder