weihanglo / sfz

A simple static file serving command-line tool written in Rust.
https://crates.io/crates/sfz
Apache License 2.0
400 stars 30 forks source link

Proper logging #101

Closed henry40408 closed 1 year ago

henry40408 commented 2 years ago

closes #96


Send request with curl

$ curl http://localhost:5000/Cargo.toml
127.0.0.1 - - [24/Sep/2022 16:14:55 +0800] "GET /Cargo.toml HTTP/1.1" 200 1535 "-" "curl/7.68.0" "-"

Enable compression and send request with curl

$ curl --compressed http://localhost:5000/Cargo.toml
127.0.0.1 - - [24/Sep/2022 16:15:29 +0800] "GET /Cargo.toml HTTP/1.1" 200 859 "-" "curl/7.68.0" "-"

Send request with HTTPie

$ http http://localhost:5000/Cargo.toml
127.0.0.1 - - [24/Sep/2022 16:16:00 +0800] "GET /Cargo.toml HTTP/1.1" 200 739 "-" "HTTPie/1.0.3" "-"

Performance is not compromised

$ wrk http://localhost:5000/Cargo.toml
Running 10s test @ http://localhost:5000/Cargo.toml
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.29ms    1.27ms  23.19ms   92.44%
    Req/Sec     4.58k   715.61     5.63k    67.50%
  91141 requests in 10.00s, 156.54MB read
Requests/sec:   9111.59
Transfer/sec:     15.65MB

Partial content log

$ curl -r 10-20 http://localhost:5000/Cargo.toml
127.0.0.1 - - [24/Sep/2022 16:48:41 +0800] "GET /Cargo.toml HTTP/1.1" 206 11 "-" "curl/7.68.0" "-"