Unverified Commit ba70e0e0 authored by Mouad Debbar's avatar Mouad Debbar Committed by GitHub

Print correct hostname when web server is launched (#42531)

parent 8cc9a53e
......@@ -209,6 +209,7 @@ class WebFs {
};
// Initialize the dwds server.
final String effectiveHostname = hostname ?? _kHostName;
final int hostPort = port == null ? await os.findFreePort() : int.tryParse(port);
final Pipeline pipeline = const Pipeline().addMiddleware((Handler innerHandler) {
......@@ -279,10 +280,10 @@ class WebFs {
final BuildRunnerAssetHandler assetHandler = BuildRunnerAssetHandler(
daemonAssetPort,
kBuildTargetName,
hostname ?? _kHostName,
effectiveHostname,
hostPort);
dwds = await dwdsFactory(
hostname: hostname ?? _kHostName,
hostname: effectiveHostname,
assetHandler: assetHandler,
buildResults: filteredBuildResults,
chromeConnection: () async {
......@@ -309,13 +310,13 @@ class WebFs {
Cascade cascade = Cascade();
cascade = cascade.add(handler);
cascade = cascade.add(assetServer.handle);
final HttpServer server = await httpMultiServerFactory(hostname ?? _kHostName, hostPort);
final HttpServer server = await httpMultiServerFactory(effectiveHostname, hostPort);
shelf_io.serveRequests(server, cascade.handler);
final WebFs webFS = WebFs(
client,
server,
dwds,
'http://$_kHostName:$hostPort/',
'http://$effectiveHostname:$hostPort/',
assetServer,
buildInfo.isDebug,
flutterProject,
......
......@@ -167,7 +167,7 @@ void main() {
test('Uses provided port number and hostname.', () => testbed.run(() async {
final FlutterProject flutterProject = FlutterProject.current();
await WebFs.start(
final WebFs webFs = await WebFs.start(
skipDwds: false,
target: fs.path.join('lib', 'main.dart'),
buildInfo: BuildInfo.debug,
......@@ -177,6 +177,7 @@ void main() {
port: '1234',
);
expect(webFs.uri, contains('foo:1234'));
expect(lastPort, 1234);
expect(lastAddress, contains('foo'));
}));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment