1️⃣Base Stage
Respond with 200

Extract URL path

Respond with body

Read header

Concurrent connections

Return a file

Read request body

2️⃣ HTTP Compression
Compression headers

Multiple compression schemes

Gzip compression

3️⃣ Persistent Connections
Persistent connections

Concurrent persistent connections

Connection closure

log
[compile] -- Running vcpkg install
[compile] Detecting compiler hash for triplet x64-linux...
[compile] Compiler found: /usr/local/bin/c++
[compile] The following packages are already installed:
[compile] pthreads:x64-linux@3.0.0#14 -- git+https://github.com/microsoft/vcpkg@2e0a6df2800d3677b941dc6504f083965b7886d9
[compile] * vcpkg-cmake:x64-linux@2023-05-04 -- git+https://github.com/microsoft/vcpkg@88a7058fc7fa73a9c4c99cfcae9d79e2abf87a5a
[compile] * vcpkg-cmake-config:x64-linux@2022-02-06#1 -- git+https://github.com/microsoft/vcpkg@8d54cc4f487d51b655abec5f9c9c3f86ca83311f
[compile] zlib:x64-linux@1.3.1 -- git+https://github.com/microsoft/vcpkg@3f05e04b9aededb96786a911a16193cdb711f0c9
[compile] All requested installations completed successfully in: 53.6 us
[compile] -- Running vcpkg install - done
[compile] -- Configuring done (0.4s)
[compile] -- Generating done (0.0s)
[compile] -- Build files have been written to: /app/build
[compile] [ 50%] Building CXX object CMakeFiles/http-server.dir/src/main.cpp.o
[compile] [100%] Linking CXX executable http-server
[compile] [100%] Built target http-server
[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.
[tester::#KH7] Running tests for Stage #KH7 (Persistent Connections - Connection closure)
[tester::#KH7] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[your_program] Client connected
[tester::#KH7] $ curl --http1.1 -v http://localhost:4221/user-agent -H "User-Agent: strawberry/strawberry" --next http://localhost:4221/user-agent -H "Connection: close" -H "User-Agent: apple/banana-mango"
[your_program] Received request:
[your_program] GET /user-agent HTTP/1.1
[your_program] Host: localhost:4221
[your_program] User-Agent: strawberry/strawberry
[your_program]
[your_program]
[your_program] Method: GET, Path: /user-agent
[tester::#KH7] Received response with 200 status code
[tester::#KH7] ✓ Content-Type header is present
[tester::#KH7] ✓ Content-Length header is present
[tester::#KH7] ✓ Body is correct
[your_program] Received request:
[tester::#KH7] Received response with 200 status code
[tester::#KH7] ✓ Content-Type header is present
[tester::#KH7] ✓ Content-Length header is present
[tester::#KH7] ✓ Connection header is present
[tester::#KH7] ✓ Body is correct
[your_program] GET /user-agent HTTP/1.1
[tester::#KH7] Connection #0 is closed
[your_program] Host: localhost:4221
[tester::#KH7] Test passed.
[your_program] Connection: close
[your_program] User-Agent: apple/banana-mango
[your_program]
[your_program]
[your_program] Method: GET, Path: /user-agent
[tester::#UL1] Running tests for Stage #UL1 (Persistent Connections - Concurrent persistent connections)
[tester::#UL1] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[your_program] Client connected
[tester::#UL1] $ curl --http1.1 -v http://localhost:4221/echo/grape http://localhost:4221/echo/strawberry
[your_program] Client connected
[your_program] Received request:
[tester::#UL1] Received response with 200 status code
[tester::#UL1] ✓ Content-Type header is present
[your_program] GET /echo/strawberry HTTP/1.1
[tester::#UL1] ✓ Content-Length header is present
[tester::#UL1] ✓ Body is correct
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /echo/strawberry
[your_program] Received request:
[your_program] GET /echo/grape HTTP/1.1
[tester::#UL1] Received response with 200 status code
[tester::#UL1] ✓ Content-Type header is present
[tester::#UL1] ✓ Content-Length header is present
[tester::#UL1] ✓ Body is correct
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /echo/grape
[tester::#UL1] $ curl --http1.1 -v http://localhost:4221/echo/grape http://localhost:4221/echo/strawberry
[your_program] Received request:
[tester::#UL1] Received response with 200 status code
[tester::#UL1] ✓ Content-Type header is present
[tester::#UL1] ✓ Content-Length header is present
[tester::#UL1] ✓ Body is correct
[your_program] GET /echo/grape HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /echo/grape
[your_program] Received request:
[your_program] GET /echo/strawberry HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[tester::#UL1] Received response with 200 status code
[your_program]
[tester::#UL1] ✓ Content-Type header is present
[tester::#UL1] ✓ Content-Length header is present
[tester::#UL1] ✓ Body is correct
[your_program] Method: GET, Path: /echo/strawberry
[tester::#UL1] Test passed.
[tester::#AG9] Running tests for Stage #AG9 (Persistent Connections - Persistent connections)
[tester::#AG9] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[your_program] Client connected
[tester::#AG9] $ curl --http1.1 -v http://localhost:4221/ --next http://localhost:4221/user-agent -H "User-Agent: blueberry/strawberry-orange"
[your_program] Received request:
[your_program] GET / HTTP/1.1
[tester::#AG9] Received response with 200 status code
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /
[your_program] Received request:
[tester::#AG9] Received response with 200 status code
[tester::#AG9] ✓ Content-Type header is present
[tester::#AG9] ✓ Content-Length header is present
[tester::#AG9] ✓ Body is correct
[your_program] GET /user-agent HTTP/1.1
[your_program] Host: localhost:4221
[your_program] User-Agent: blueberry/strawberry-orange
[your_program]
[your_program]
[your_program] Method: GET, Path: /user-agent
[tester::#AG9] Test passed.
[tester::#CR8] Running tests for Stage #CR8 (HTTP Compression - Gzip compression)
[tester::#CR8] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[tester::#CR8] $ curl -v http://localhost:4221/echo/pineapple -H "Accept-Encoding: gzip"
[your_program] Client connected
[your_program] Received request:
[your_program] GET /echo/pineapple HTTP/1.1
[your_program] Host: localhost:4221
[your_program] Accept-Encoding: gzip
[your_program]
[your_program]
[your_program] Method: GET, Path: /echo/pineapple
[tester::#CR8] Received response with 200 status code
[tester::#CR8] ✓ Content-Encoding header is present
[tester::#CR8] ✓ Content-Length header is present
[tester::#CR8] ✓ Body is gzip encoded
[tester::#CR8] ✓ Body is correct
[tester::#CR8] Test passed.
[tester::#IJ8] Running tests for Stage #IJ8 (HTTP Compression - Multiple compression schemes)
[tester::#IJ8] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[tester::#IJ8] $ curl -v http://localhost:4221/echo/pineapple -H "Accept-Encoding: encoding-1, gzip, encoding-2"
[your_program] Client connected
[your_program] Received request:
[your_program] GET /echo/pineapple HTTP/1.1
[your_program] Host: localhost:4221
[your_program] Accept-Encoding: encoding-1, gzip, encoding-2
[your_program]
[your_program]
[tester::#IJ8] Received response with 200 status code
[tester::#IJ8] ✓ Content-Encoding header is present
[your_program] Method: GET, Path: /echo/pineapple
[tester::#IJ8] First test passed.
[your_program] Client connected
[tester::#IJ8] $ curl -v http://localhost:4221/echo/pineapple -H "Accept-Encoding: encoding-1, encoding-2"
[tester::#IJ8] Received response with 200 status code
[your_program] Received request:
[your_program] GET /echo/pineapple HTTP/1.1
[your_program] Host: localhost:4221
[your_program] Accept-Encoding: encoding-1, encoding-2
[your_program]
[your_program]
[your_program] Method: GET, Path: /echo/pineapple
[tester::#IJ8] ✓ Content-Encoding header is not present
[tester::#IJ8] Test passed.
[tester::#DF4] Running tests for Stage #DF4 (HTTP Compression - Compression headers)
[tester::#DF4] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[tester::#DF4] $ curl -v http://localhost:4221/echo/pear -H "Accept-Encoding: gzip"
[your_program] Client connected
[tester::#DF4] Received response with 200 status code
[your_program] Received request:
[tester::#DF4] ✓ Content-Encoding header is present
[your_program] GET /echo/pear HTTP/1.1
[your_program] Host: localhost:4221
[your_program] Accept-Encoding: gzip
[your_program]
[your_program]
[your_program] Method: GET, Path: /echo/pear
[tester::#DF4] First test passed.
[your_program] Client connected
[tester::#DF4] $ curl -v http://localhost:4221/echo/pear -H "Accept-Encoding: invalid-encoding"
[your_program] Received request:
[your_program] GET /echo/pear HTTP/1.1
[tester::#DF4] Received response with 200 status code
[your_program] Host: localhost:4221
[your_program] Accept-Encoding: invalid-encoding
[your_program]
[your_program]
[your_program] Method: GET, Path: /echo/pear
[tester::#DF4] ✓ Content-Encoding header is not present
[tester::#DF4] Test passed.
[tester::#QV8] Running tests for Stage #QV8 (Read request body)
[tester::#QV8] $ ./your_program.sh --directory /tmp/data/codecrafters.io/http-server-tester/
[your_program] Logs from your program will appear here!
[your_program] Directory: /tmp/data/codecrafters.io/http-server-tester/
[your_program] Waiting for a client to connect...
[your_program] Client connected
[tester::#QV8] $ curl -v -X POST http://localhost:4221/files/pineapple_pineapple_orange_apple -H "Content-Length: 72" -H "Content-Type: application/octet-stream" -d 'banana raspberry raspberry blueberry strawberry strawberry orange banana'
[your_program] Received request:
[your_program] POST /files/pineapple_pineapple_orange_apple HTTP/1.1
[your_program] Host: localhost:4221
[your_program] Content-Length: 72
[your_program] Content-Type: application/octet-stream
[your_program]
[your_program] banana raspberry raspberry blueberry strawberry strawberry orange banana
[your_program] Method: POST, Path: /files/pineapple_pineapple_orange_apple
[tester::#QV8] Received response with 201 status code
[tester::#QV8] Test passed.
[tester::#AP6] Running tests for Stage #AP6 (Return a file)
[tester::#AP6] $ ./your_program.sh --directory /tmp/data/codecrafters.io/http-server-tester/
[tester::#AP6] Testing existing file
[your_program] Logs from your program will appear here!
[your_program] Directory: /tmp/data/codecrafters.io/http-server-tester/
[your_program] Waiting for a client to connect...
[tester::#AP6] $ curl -v http://localhost:4221/files/grape_banana_banana_strawberry
[your_program] Client connected
[your_program] Received request:
[your_program] GET /files/grape_banana_banana_strawberry HTTP/1.1
[tester::#AP6] Received response with 200 status code
[tester::#AP6] ✓ Content-Type header is present
[tester::#AP6] ✓ Content-Length header is present
[tester::#AP6] ✓ Body is correct
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /files/grape_banana_banana_strawberry
[tester::#AP6] First test passed.
[tester::#AP6] Testing non existent file returns 404
[tester::#AP6] $ curl -v http://localhost:4221/files/non-existentgrape_pineapple_banana_apple
[your_program] Client connected
[your_program] Received request:
[your_program] GET /files/non-existentgrape_pineapple_banana_apple HTTP/1.1
[tester::#AP6] Received response with 404 status code
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /files/non-existentgrape_pineapple_banana_apple
[tester::#AP6] Test passed.
[tester::#EJ5] Running tests for Stage #EJ5 (Concurrent connections)
[tester::#EJ5] $ ./your_program.sh
[tester::#EJ5] Creating 2 parallel connections
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[your_program] Client connected
[your_program] Client connected
[tester::#EJ5] client-2: $ curl -v http://localhost:4221/
[tester::#EJ5] Received response with 200 status code
[your_program] Received request:
[your_program] GET / HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /
[tester::#EJ5] client-1: $ curl -v http://localhost:4221/
[tester::#EJ5] Received response with 200 status code
[your_program] Received request:
[your_program] GET / HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /
[tester::#EJ5] Creating 2 parallel connections
[your_program] Client connected
[your_program] Client connected
[tester::#EJ5] client-1: $ curl -v http://localhost:4221/
[tester::#EJ5] Received response with 200 status code
[your_program] Received request:
[your_program] GET / HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /
[tester::#EJ5] client-2: $ curl -v http://localhost:4221/
[tester::#EJ5] Received response with 200 status code
[your_program] Received request:
[your_program] GET / HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /
[tester::#EJ5] Test passed.
[tester::#FS3] Running tests for Stage #FS3 (Read header)
[tester::#FS3] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[your_program] Client connected
[tester::#FS3] $ curl -v http://localhost:4221/user-agent -H "User-Agent: banana/raspberry"
[tester::#FS3] Received response with 200 status code
[tester::#FS3] ✓ Content-Type header is present
[tester::#FS3] ✓ Content-Length header is present
[tester::#FS3] ✓ Body is correct
[your_program] Received request:
[your_program] GET /user-agent HTTP/1.1
[your_program] Host: localhost:4221
[your_program] User-Agent: banana/raspberry
[your_program]
[your_program]
[your_program] Method: GET, Path: /user-agent
[tester::#FS3] Test passed.
[tester::#CN2] Running tests for Stage #CN2 (Respond with body)
[tester::#CN2] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[tester::#CN2] $ curl -v http://localhost:4221/echo/pineapple
[your_program] Client connected
[your_program] Received request:
[your_program] GET /echo/pineapple HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[your_program]
[tester::#CN2] Received response with 200 status code
[tester::#CN2] ✓ Content-Type header is present
[tester::#CN2] ✓ Content-Length header is present
[tester::#CN2] ✓ Body is correct
[your_program] Method: GET, Path: /echo/pineapple
[tester::#CN2] Test passed.
[tester::#IH0] Running tests for Stage #IH0 (Extract URL path)
[tester::#IH0] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[tester::#IH0] $ curl -v http://localhost:4221/strawberry
[your_program] Client connected
[your_program] Received request:
[tester::#IH0] Received response with 404 status code
[your_program] GET /strawberry HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /strawberry
[tester::#IH0] Test passed.
[tester::#IA4] Running tests for Stage #IA4 (Respond with 200)
[tester::#IA4] $ ./your_program.sh
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[tester::#IA4] $ curl -v http://localhost:4221/
[your_program] Client connected
[your_program] Received request:
[tester::#IA4] Received response with 200 status code
[your_program] GET / HTTP/1.1
[your_program] Host: localhost:4221
[your_program]
[your_program]
[your_program] Method: GET, Path: /
[tester::#IA4] Test passed.
[tester::#AT4] Running tests for Stage #AT4 (Bind to a port)
[tester::#AT4] $ ./your_program.sh
[tester::#AT4] Connecting to localhost:4221 using TCP
[your_program] Logs from your program will appear here!
[your_program] Directory:
[your_program] Waiting for a client to connect...
[tester::#AT4] Success! Closing connection
[tester::#AT4] Test passed.
[your_program] Client connected
喜欢这篇文章的人也看了
评论
隐私政策
0/500
滚动到此处加载评论...



