yarn install
yarn dev --directory ./filesHTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 0
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 0
HTTP/1.1 404 Not Found
Content-Type: text/plain
Content-Length: 0
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 9
pineapple
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 19
raspberry/blueberry
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 0
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 0
HTTP/1.1 200 OK
Content-Length: 14
Content-Type: application/octet-stream
Hello, World!
HTTP/1.1 404 Not Found
Content-Type: text/plain
Content-Length: 0
curl -v -X POST http://localhost:4221/files/bar -H "Content-Length: 73" -H "Content-Type: application/octet-stream" -d 'orange pineapple blueberry raspberry strawberry apple raspberry raspberry' && cat ./files/bar
HTTP/1.1 201 Created
Content-Type: text/plain
Content-Length: 0
orange pineapple blueberry raspberry strawberry apple raspberry raspberry
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Type: text/plain
Content-Length: 24
00000000 1f 8b 08 00 00 00 00 00 00 13 2b 48 4d 2c 02 00 |..........+HM,..|
00000010 bd 3c 8a c6 04 00 00 00 |.<......|
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 4
pear
curl -v http://localhost:4221/echo/apple -H "Accept-Encoding: encoding-1, gzip, encoding-2" | hexdump -C
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Type: text/plain
Content-Length: 25
00000000 1f 8b 08 00 00 00 00 00 00 13 4b 2c 28 c8 49 05 |..........K,(.I.|
00000010 00 50 d0 2e a9 05 00 00 00 |.P.......|
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 5
apple
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Type: text/plain
Content-Length: 26
00000000 1f 8b 08 00 00 00 00 00 00 13 4b 4a cc 4b cc 4b |..........KJ.K.K|
00000010 04 00 cf 67 8b 03 06 00 00 00 |...g......|
curl --http1.1 -v http://localhost:4221/ --next http://localhost:4221/user-agent -H "User-Agent: strawberry/apple"
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 0
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 16
strawberry/apple
curl --http1.1 -v http://localhost:4221/user-agent -H "User-Agent: orange/pineapple" --next http://localhost:4221/user-agent -H "User-Agent: pear/apple-banana" (2x)
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 16
orange/pineapple
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 17
pear/apple-banana
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 16
orange/pineapple
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 17
pear/apple-banana
curl --http1.1 -v http://localhost:4221/ --next http://localhost:4221/echo/blueberry -H "Connection: close"
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 0
HTTP/1.1 200 OK
Connection: close
Content-Type: text/plain
Content-Length: 9
* Closing connection
blueberry
This is a starting point for TypeScript solutions to the "Build Your Own HTTP server" Challenge.
HTTP is the protocol that powers the web. In this challenge, you'll build a HTTP/1.1 server that is capable of serving multiple clients.
Along the way you'll learn about TCP servers, HTTP request syntax, and more.
Note: If you're viewing this repo on GitHub, head over to codecrafters.io to try the challenge.
The entry point for your HTTP server implementation is in app/main.ts. Study
and uncomment the relevant code, and push your changes to pass the first stage:
git commit -am "pass 1st stage" # any msg
git push origin masterTime to move on to the next stage!
Note: This section is for stages 2 and beyond.
- Ensure you have
bun (1.2)installed locally - Run
./your_program.shto run your program, which is implemented inapp/main.ts. - Commit your changes and run
git push origin masterto submit your solution to CodeCrafters. Test output will be streamed to your terminal.