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#

  1. Setup & Isolation - XDG directories, environment
  2. Basic Requests - GET with/without query params
  3. Response Headers - Status codes (200, 404, 500)
  4. Custom Headers - X-Custom-Header, User-Agent
  5. Cookies - Set, read, delete with cookie jar
  6. POST Requests - Form data, JSON, file uploads
  7. Other Methods - PUT, DELETE
  8. Redirects - Following, chains, absolute
  9. Authentication - Basic auth, Bearer tokens
  10. Response Inspection - Headers, content negotiation, delays
  11. Compression - gzip, deflate
  12. Request Introspection - IP, headers, user-agent
  13. Response Formats - JSON, HTML, XML, UTF-8
  14. Binary Data - PNG, JPEG images
  15. Response Size - Bytes, streaming
  16. Range Requests - Partial content
  17. Error Handling - Timeouts, 404s
  18. 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