Skip to content

Latest commit

 

History

History
39 lines (33 loc) · 2.35 KB

README.md

File metadata and controls

39 lines (33 loc) · 2.35 KB

progress-banner

This is a repo for Rust solutions to the http-server challenge on Codecrafters.

Challenge Status

The entry point for this http-server implementation is in src/main.rs. This simple http-server implementation includes:

  • user-friendly API for parsing HTTP requests
  • user-friendly, elegant, and type-safe API for building HTTP responses
  • support for concurrent connections handling using thread pool with a configurable number of threads (deprecated in favor of async/await)
  • support for concurrent connections handling using multi-threading with async/await
  • compression support for the server using the flate2 crate:
    • compresses the response body if the client supports it
  • support for the following endpoints:
    • / - returns 200 OK status code
    • /echo/<string_to_return> - echoes the string passed by user in the URL
    • /user-agent - echoes the User-Agent header value
    • /files/{filename} - returns the content of the file with the name filename in the specified directory
    • /files/{filename} - saves the content of the response to the file with the name filename in the specified directory

Running the Server

  1. Ensure you have cargo (>=1.70) installed locally
  2. Run ./your_server.sh to run your program, which is implemented in src/main.rs. This command compiles your Rust project, so it might be slow the first time you run the http-server on http://127.0.0.1:4221. Subsequent runs will be fast.
  3. Open a new tab in the terminal and send requests to the server using curl or netcat. To test the performance of the server, you can use the oha CLI tool to send a large number of concurrent requests to the server and get the performance metrics in a nice TUI interface. An example of how to use oha is shown below:
# Send 10000 requests with 10 concurrent connections
$ oha -n 10000 -c 10 http://127.0.0.1:4221/echo/hello