Interface FcHttpClient
- All Known Implementing Classes:
ApacheFcHttpClient
public interface FcHttpClient
Frontcache's own origin-fetch abstraction - the extension points' view of "go get this URL".
Until 2.8 the three reflection-loaded SPIs (
CacheProcessor, IncludeProcessor,
FallbackResolver) took an Apache HttpClient in their signatures - the 4.5-era
org.apache.http.client.HttpClient. That leaked a third-party type into a public contract:
the HttpClient 4.5 -> 5.x upgrade broke every implementation, and so would the next such upgrade.
The parameter was only ever threaded through to three leaf calls, and all three mean the same
thing - fetch a URL, hand back a WebResponse. Nothing needed a connection pool, a route
planner or an entity. So the SPIs take this instead, and the Apache types stay inside
ApacheFcHttpClient and the resilience commands. See
docs/archive/httpclient5-upgrade-proposal.md section 5.1.
The three methods are not redundant - each corresponds to one of those leaf uses, and they differ
in ways a caller cannot paper over (which transport, whether a circuit breaker is involved, and
whether a non-2xx is an exception or a result).
Implementations are supplied by Frontcache; third parties consume this, they do not implement it.-
Method Summary
Modifier and TypeMethodDescriptionOne-shot GET with no resilience wrapper and no request context - for bootstrap-time downloads such as prefetching fallback pages.Fetch through whichever origin transport this node uses: an HTTP call in standalone mode, the origin app's own filter chain in webfilter mode.fetchOverHttp(String urlStr, Map<String, List<String>> requestHeaders, RequestContext context) Fetch over HTTP specifically, never the filter chain.
-
Method Details
-
fetch
WebResponse fetch(String urlStr, Map<String, List<String>> requestHeaders, RequestContext context) throws FrontCacheException Fetch through whichever origin transport this node uses: an HTTP call in standalone mode, the origin app's own filter chain in webfilter mode. Resilience-wrapped (circuit breaker, bulkhead, time limiter, fallback).- Parameters:
urlStr- absolute origin URLrequestHeaders- headers to forward; the caller owns the map and it may be mutatedcontext- the per-request context this fetch belongs to- Returns:
- the origin response as a cacheable
WebResponse - Throws:
FrontCacheException
-
fetchOverHttp
WebResponse fetchOverHttp(String urlStr, Map<String, List<String>> requestHeaders, RequestContext context) throws FrontCacheException Fetch over HTTP specifically, never the filter chain. Includes always use this: an include is a different URL from the one being served, so re-running the current request's filter chain would return the wrong page. Resilience-wrapped likefetch(String, Map, RequestContext).- Throws:
FrontCacheException
-
fetch
One-shot GET with no resilience wrapper and no request context - for bootstrap-time downloads such as prefetching fallback pages. The body is materialised into the returnedWebResponse, which is fine for the small, few, once-per-startup fetches this is for. Unlike the two request-path methods, a non-2xx status is a normal return, not an exception: callers decide what a 404 on a fallback page means.- Throws:
FrontCacheException
-