IoHttpTransport class
The HttpTransport for platforms with dart:io (the Dart VM, Flutter
on mobile and desktop), built on dart:io's HttpClient.
platformHttpTransport() returns one on these platforms, so you create
it yourself only to configure the HttpClient: a proxy, trusted
certificates, a user agent. Declare it as an HttpTransport bean and
the Feign starter uses it.
How it treats an HttpRequest:
- Its headers replace the
HttpClientdefaults of the same name (User-Agent,Accept-Encoding);Content-Lengthis always taken from the body. - Redirects are followed when
followRedirectsis set, as far asHttpClientfollows them: forGETandHEAD, and a303after aPOST. readTimeoutlimits each wait for data (the response, then every chunk of the body) andtimeoutthe whole exchange. When one runs out the request is aborted and an HttpTransportException withisTimeoutis thrown.- Socket and other I/O errors become an HttpTransportException
whose
causeis the original error.
import 'dart:io';
import 'package:spring_web_dart/io.dart';
// Feign calls go through the company proxy.
@Configuration()
class HttpSetup {
@Bean()
HttpTransport httpTransport() => IoHttpTransport(
connectTimeout: const Duration(seconds: 3),
client: HttpClient()
..findProxy = (_) => 'PROXY proxy.neon.books:3128',
);
}
Spring (Java): JdkClientHttpRequestFactory, on the JDK's
HttpClient:
var factory = new JdkClientHttpRequestFactory(HttpClient.newHttpClient());
factory.setReadTimeout(Duration.ofSeconds(5));
- Implemented types
Constructors
- IoHttpTransport({Duration? connectTimeout, HttpClient? client})
-
A transport that sends through
client, or through a newHttpClientwhen none is given.connectTimeout, when set, becomes the client'sconnectionTimeout: the longest wait for a connection to open. close closes the client, also one passed in.
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.
override
-
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.override -
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.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited