A batteries included HTTP/1.1 client in OCaml
httpbin.t Quick Reference#
What This Tests#
This cram test validates HTTP client functionality through curl against a httpbin server.
Test Categories#
- Setup & Isolation - XDG directories, environment
- Basic Requests - GET with/without query params
- Response Headers - Status codes (200, 404, 500)
- Custom Headers - X-Custom-Header, User-Agent
- Cookies - Set, read, delete with cookie jar
- POST Requests - Form data, JSON, file uploads
- Other Methods - PUT, DELETE
- Redirects - Following, chains, absolute
- Authentication - Basic auth, Bearer tokens
- Response Inspection - Headers, content negotiation, delays
- Compression - gzip, deflate
- Request Introspection - IP, headers, user-agent
- Response Formats - JSON, HTML, XML, UTF-8
- Binary Data - PNG, JPEG images
- Response Size - Bytes, streaming
- Range Requests - Partial content
- Error Handling - Timeouts, 404s
- Cleanup - Remove test artifacts
Running Tests#
# Start httpbin first
docker run -p 8088:80 kennethreitz/httpbin
# Run tests with default URL
dune test test/httpbin.t
# Or with custom URL
HTTPBIN_URL=http://localhost:9000 dune test test/httpbin.t
Updating Expectations#
If test output changes and is correct:
dune promote test/httpbin.t
Key Features#
- ✅ Isolated XDG directories (no user config pollution)
- ✅ Parameterized httpbin URL via environment variable
- ✅ Cookie jar isolation within test directory
- ✅ Comprehensive HTTP feature coverage
- ✅ Automatic cleanup after tests
- ✅ Works with any httpbin-compatible endpoint