Class ApacheHttpClient
- All Implemented Interfaces:
HttpClient,Closeable,AutoCloseable,org.apache.hc.core5.http.HttpRequestInterceptor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()voidapply(KarateConfig config) Apply a typed configuration snapshot.voidclose()invoke(HttpRequest request) voidprocess(org.apache.hc.core5.http.HttpRequest hr, org.apache.hc.core5.http.EntityDetails entity, org.apache.hc.core5.http.protocol.HttpContext context) protected org.apache.hc.client5.http.io.HttpClientConnectionManagerThe connection manager this client should use, or null to build a private one per instance — which is the default and what every functional test wants.
-
Constructor Details
-
ApacheHttpClient
public ApacheHttpClient()
-
-
Method Details
-
apply
Description copied from interface:HttpClientApply a typed configuration snapshot.KarateConfigis the single source of truth — implementations read every relevant setting via its typed getters and (re)build their internal client state.Must be idempotent: an implementation may not tear down or rebuild anything when the settings it cares about are unchanged. This is a requirement rather than an optimisation, because it is what lets callers stop deciding. Config reaches a client from four places — a
configure <key>step, a shared-scope call returning, a callee inheriting from its caller, and a cachedcalloncereplaying — and the last three copy a whole config across a scenario boundary with no key to test. Any caller-side shortcut therefore has to be conservative on those paths, which means rebuilding a live client and its connection pool for a config that did not change. Deciding here, against the settings actually in use, is the only place the question can be answered exactly.Callers should call this whenever config may have changed and let the implementation sort it out. They must not try to predict the answer.
- Specified by:
applyin interfaceHttpClient
-
invoke
- Specified by:
invokein interfaceHttpClient
-
abort
public void abort()- Specified by:
abortin interfaceHttpClient
-
process
public void process(org.apache.hc.core5.http.HttpRequest hr, org.apache.hc.core5.http.EntityDetails entity, org.apache.hc.core5.http.protocol.HttpContext context) - Specified by:
processin interfaceorg.apache.hc.core5.http.HttpRequestInterceptor
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-