The low-level HTTP client: it sends an HttpRequest over the network and gives back the response, without knowing about JSON, annotations or error handling.
It exists so that the clients built on it (Feign clients today) do not depend on how a platform does HTTP. Three implementations come with this package:
IoHttpTransportondart:io(the VM, Flutter on mobile and desktop), frompackage:spring_web_dart/io.dart;FetchHttpTransporton the browser'sfetch, frompackage:spring_web_dart/browser.dart;MockHttpTransportfor tests, frompackage:spring_web_dart/testing.dart.
Most applications never call it. The Feign starter declares an
httpTransport bean from platformHttpTransport and its clients use
it. You implement this interface to put Feign on another HTTP library
(Dio, package:http, a client with certificate pinning) and declare
your implementation as a bean: the starter then uses it instead.
// A one-off call outside any Feign client.
final transport = platformHttpTransport();
try {
final response = await transport.send(
HttpRequest(
method: HttpMethod.get,
url: Uri.parse('https://api.neon.books/books/1'),
),
);
log.info(response.bodyText);
} finally {
transport.close(); // Frees the pooled connections.
}
Spring (Java): ClientHttpRequestFactory, the layer under
RestTemplate and RestClient:
ClientHttpRequestFactory factory = new JdkClientHttpRequestFactory();
ClientHttpResponse response =
factory.createRequest(uri, HttpMethod.GET).execute();
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → void - Releases the transport's connections. Call it when the transport is no longer needed (the Feign starter does when the application stops); do not use the transport afterwards.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
HttpRequest request) → Future< HttpResponse> -
Sends
requestand reads the whole response into memory. -
stream(
HttpRequest request) → Future< StreamedHttpResponse> -
Sends
requestand completes as soon as the status and headers have arrived. The body is then read from StreamedHttpResponse.body as it comes. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited