we (web engine): Experimental web browser project to understand the limits of Claude

HTTP/1.1 client with connection pooling #63

open opened by pierrelf.com

Phase 6: HTTP/1.1 Client with Connection Pooling#

Implement the high-level HTTP/1.1 client in the net crate, bringing together TCP, TLS, DNS, URL, and HTTP parsing.

Requirements#

  • HttpClient type:
    • get(url: &Url) -> Result<HttpResponse>
    • post(url: &Url, body: &[u8], content_type: &str) -> Result<HttpResponse>
    • request(method: Method, url: &Url, headers: &Headers, body: Option<&[u8]>) -> Result<HttpResponse>
  • Scheme handling:
    • http:// — plain TCP connection
    • https:// — TLS connection with certificate verification
  • Connection lifecycle:
    • DNS resolve hostname → connect TCP → (optional TLS handshake) → send request → read response
    • Respect Connection: keep-alive / Connection: close headers
  • Connection pooling:
    • Pool idle connections by (host, port, is_tls) key
    • Reuse connections for subsequent requests to same origin
    • Max idle time before closing (e.g., 60 seconds)
    • Max connections per host (e.g., 6)
  • Redirect following: follow 301, 302, 307, 308 redirects (configurable max redirects)
  • User-Agent: we-browser/0.1

Dependencies#

  • WHATWG URL parser
  • TCP socket wrapper
  • DNS stub resolver
  • TLS 1.3 client (handshake + record layer + key schedule)
  • HTTP/1.1 parser

Acceptance Criteria#

  • Fetch HTTP URLs over plain TCP
  • Fetch HTTPS URLs with TLS 1.3
  • Connection pooling with keep-alive reuse
  • Redirect following (301, 302, 307, 308)
  • Proper Host header from URL
  • Timeout support for connect and read
  • Integration test: fetch a real HTTPS page
  • Tests (15+ unit tests + integration tests)
  • cargo clippy and cargo fmt clean
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mguymiqwe62u