Browse documentation

How it works

On this page

What happens between Http.Get and the TResponse you get back.

A request, end to end

Request lifecycle: your code, Request-FP pipeline, server, and the response or typed error

  1. Build. Headers, query parameters, and the body are prepared. A User-Agent is added unless you set one.
  2. Connect. https:// URLs load OpenSSL on first use. http:// URLs go through a proxy when one is set.
  3. Follow redirects. Cookies are re-matched for each new URL, and Authorization is dropped if the redirect leaves the host.
  4. Retry if it is safe. See below.
  5. Return. Any HTTP status becomes a TResponse. A transport failure raises ETimeoutError, ENetworkError, or ERequestError, or fills TRequestResult for Try* methods.

Records with management operators free everything automatically: there is no client object to free, and Response.JSON is owned by the response.

Retries

Retry timeline: 503, wait 250 ms, network error, wait 500 ms, then 200 OK

Change it with Http.SetRetry(Count, FirstDelayMS); SetRetry(0, 0) turns it off.

Cookies and redirects in a session

Login redirect: cookies follow the session on the same host, and are dropped with credentials on a cross-host redirect

Streaming downloads

Download flow: bytes stream into file.part, which becomes the file only after a complete 2xx response

Uploads work the same way in reverse: PostMultipart reads each file from disk while sending.

Errors

Exception
└── ERequestError        any Request-FP failure
    └── ENetworkError    connection, DNS, socket, TLS, server closed early
        └── ETimeoutError connect timeout or I/O timeout

Catch the most specific class first. HTTP error statuses are not exceptions unless you call Response.RaiseForStatus.

See Technical details for FPC and OpenSSL internals.