https://github.com/pablo-mayrgundter/http
A simple multi-threaded HTTP/1.0-ish file server. Single file, ~250 LOC.
https://github.com/pablo-mayrgundter/http
http java server web
Last synced: about 1 year ago
JSON representation
A simple multi-threaded HTTP/1.0-ish file server. Single file, ~250 LOC.
- Host: GitHub
- URL: https://github.com/pablo-mayrgundter/http
- Owner: pablo-mayrgundter
- Created: 2020-05-23T08:24:20.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-03T03:49:58.000Z (about 5 years ago)
- Last Synced: 2025-01-16T10:31:15.912Z (about 1 year ago)
- Topics: http, java, server, web
- Language: Java
- Homepage:
- Size: 67.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# http
A simple multi-threaded HTTP/1.0-ish file server. Single file, 300 LOC.
Handles only GET requests, serving files below the directory in which
the server is started. Does Content-Type inference based on file
extensions (e.g. html, js, png, jpg).
Currently disables any type of cacheing as I use it mostly for local
development and want to avoid versioning mistakes.
Also has fledgling SSL support that has occasionally worked.
To run:
```
java net.http.Server
```
or if you can't run on priviledged ports (<1024), pick a high one:
```
java -Dport=8080 net.http.Server
java -Dport=8080 -Dssl=true net.http.Server
```
Good performance using Java's Native IO. Loadtest using acme.com's http_load:
```
> cat /proc/cpuinfo
... Intel(R) Xeon(R) CPU X5679 @ 3.20GHz ...
... Intel(R) Xeon(R) CPU X5679 @ 3.20GHz ...
... Intel(R) Xeon(R) CPU X5679 @ 3.20GHz ...
> dd if=/dev/zero of=10k.dat bs=1024 count=10
> echo "http://localhost:8080/10k.dat" > test.url
> ./http_load -p 10 -f 10000 test.url
# Throwaway
> ./http_load -p 10 -f 100000 test.url
100000 fetches, 10 max parallel, 1.024e+09 bytes, in 34.9176 seconds
10240 mean bytes/connection
2863.88 fetches/sec, 2.93262e+07 bytes/sec
msecs/connect: 0.0995282 mean, 2.717 max, 0.037 min
msecs/first-response: 3.18724 mean, 202.23 max, 0.315 min
HTTP response codes:
code 200 -- 100000
```