Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/malaksadek/simple-http-server
A simple HTTP server in Java 🌐 📂 (2019)
https://github.com/malaksadek/simple-http-server
http http-client http-server java network network-programming networking
Last synced: about 7 hours ago
JSON representation
A simple HTTP server in Java 🌐 📂 (2019)
- Host: GitHub
- URL: https://github.com/malaksadek/simple-http-server
- Owner: MalakSadek
- License: gpl-3.0
- Created: 2020-05-14T21:40:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-25T16:16:59.000Z (over 3 years ago)
- Last Synced: 2024-09-09T16:11:47.111Z (2 months ago)
- Topics: http, http-client, http-server, java, network, network-programming, networking
- Language: Java
- Size: 145 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple-HTTP-Server
A simple HTTP server in Java 🌐 📂 (2019).
This is an HTTP server implemented in Java. It supports HTTP GET, HEAD, PUT, POST, 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 .txt file.
### Installation
Clone the project:
`git clone https://github.com/MalakSadek/Simple-HTTP-Server`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 WebServerMainwhere:
* document_root is the root directory from which the server will serve documents.
* port_number is the port on which the server will listen.
* is the maximum number of clients that can connect simultaneously to the server.Example: `java WebServerMain ../www 12345 100`
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* email: [email protected]
* LinkedIn: www.linkedin.com/in/malak-sadek-17aa65164/
* website: http://malaksadekapps.com/