srvh2ch11
Version:
A simple Node.js module that creates a server supporting both HTTP/1.1 and HTTP/2 cleartext (h2c) on the same port
48 lines (35 loc) • 1.1 kB
Markdown
# Test Commands
Start the server first:
```bash
node server.mjs
```
## HTTP/1.1 Tests
```bash
# Basic GET request (HTTP/1.1)
curl -v http://localhost:3000/
# Health check
curl -v http://localhost:3000/health
# POST request with data
curl -v -X POST -H "Content-Type: application/json" \
-d '{"test": "data"}' http://localhost:3000/echo
# Force HTTP/1.1
curl -v --http1.1 http://localhost:3000/
```
## HTTP/2 Tests
```bash
# HTTP/2 with prior knowledge (h2c)
curl -v --http2-prior-knowledge http://localhost:3000/
# HTTP/2 health check
curl -v --http2-prior-knowledge http://localhost:3000/health
# HTTP/2 POST request
curl -v --http2-prior-knowledge -X POST \
-H "Content-Type: application/json" \
-d '{"test": "h2 data"}' http://localhost:3000/echo
# HTTP/1.1 to HTTP/2 upgrade (h2c)
curl -v --http2 http://localhost:3000/
```
## Expected Behavior
- HTTP/1.1 responses should show `"protocol": "1.1"`
- HTTP/2 responses should show `"protocol": "2.0"`
- All endpoints return JSON with protocol information
- The server automatically detects and handles both protocols on the same port