Skip to main content
LibHTTP is Ladybird’s HTTP/1.1 client library that handles web requests, HTTP headers, cookies, and caching. It works in conjunction with RequestServer for network operations.

HTTP request handling

HttpRequest

Build and send HTTP requests:

HTTP methods

Supported HTTP methods:

GET

Retrieve resource

POST

Submit data

PUT

Update resource

DELETE

Remove resource

HEAD

Get headers only

OPTIONS

Query supported methods

PATCH

Partial update

TRACE

Diagnostic trace

CONNECT

Establish tunnel

Parsing requests

Parse raw HTTP requests:

Header management

HeaderList

Manage HTTP headers:

Header parsing

HTTP status codes

Status handling

Status codes follow the HTTP/1.1 specification (RFC 7231). LibHTTP provides the Status enum for common status codes.

Request building patterns

GET request

POST with JSON

Form data submission

LibHTTP includes cookie support for maintaining session state:

Setting cookies

  • Domain - Cookie domain scope
  • Path - URL path scope
  • Expires - Expiration timestamp
  • Max-Age - Lifetime in seconds
  • Secure - HTTPS only
  • HttpOnly - No JavaScript access
  • SameSite - CSRF protection (Strict/Lax/None)

Caching

HTTP cache support

LibHTTP supports HTTP caching directives:

Cache directives

Cache-Control

no-cache, no-store, max-age, must-revalidate

ETag

Entity tag for conditional requests

Last-Modified

Resource modification timestamp

Expires

Explicit expiration date

Content negotiation

Accept headers

Content-Type parsing

Integration with RequestServer

LibHTTP typically works through RequestServer for actual network I/O:
LibHTTP handles HTTP protocol details but doesn’t perform actual network I/O. Use RequestServer (via IPC) for network operations.

Utilities

URL handling

LibHTTP works with URL::URL from LibURL:

Method conversion

Error handling

Advanced features

Custom headers

Range requests

Performance considerations

Reuse HeaderList objects when making multiple similar requests to reduce allocations. Clone the base headers and modify as needed.

Source location

  • Repository: ~/workspace/source/Libraries/LibHTTP/
  • Key headers: HttpRequest.h, HeaderList.h, Header.h, Status.h, Method.h
  • Cookie support: LibHTTP/Cookie/
  • Caching: LibHTTP/Cache/
LibHTTP implements HTTP/1.1 per RFC 7230-7235. HTTP/2 and HTTP/3 support is planned for future releases.