HttpClientFactory class final

Sends outgoing requests (one pooled dart:io client) or answers them from a fake. Registered as a singleton in the application container.

Constructors

HttpClientFactory({HttpClient clientFactory()?})
A factory sending through dart:io, or through clients from clientFactory in tests.

Properties

connectTimeout ↔ Duration
How long opening a connection may take, within the request's own timeout (10 s, Laravel's connect_timeout). Read when the pooled client is created.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
maxConnectionsPerHost ↔ int?
The most connections to one host at once (null: no limit); further requests wait for one. Read when the pooled client is created.
getter/setter pair
maxResponseBytes ↔ int?
The body limit of requests that do not set their own; null for none.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → void
Closes pooled connections (called when the application shuts down).
fake(Map<String, Object> stubs) → HttpFake
Answers matching requests with stubs instead of the network: URL patterns (* wildcards) to a ClientResponse, a ResponseSequence, or a function of the ClientRequest. Returns the fake, to assert what was sent.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preventStrayRequests(bool prevent) → void
When prevent, a request no stub matches throws StrayRequestException instead of reaching the network.
request() → PendingRequest
A new request to configure.
restore() → void
Removes the fake (tests that share an application).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

defaultMaxResponseBytes → const int
The largest response body read by default (32 MiB); larger ones throw ResponseTooLargeException. PendingRequest.maxResponseSize changes it per request.