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 { ...@@ -209,6 +209,7 @@ class WebFs {
}; };
// Initialize the dwds server. // Initialize the dwds server.
final String effectiveHostname = hostname ?? _kHostName;
final int hostPort = port == null ? await os.findFreePort() : int.tryParse(port); final int hostPort = port == null ? await os.findFreePort() : int.tryParse(port);
final Pipeline pipeline = const Pipeline().addMiddleware((Handler innerHandler) { final Pipeline pipeline = const Pipeline().addMiddleware((Handler innerHandler) {
...@@ -279,10 +280,10 @@ class WebFs { ...@@ -279,10 +280,10 @@ class WebFs {
final BuildRunnerAssetHandler assetHandler = BuildRunnerAssetHandler( final BuildRunnerAssetHandler assetHandler = BuildRunnerAssetHandler(
daemonAssetPort, daemonAssetPort,
kBuildTargetName, kBuildTargetName,
hostname ?? _kHostName, effectiveHostname,
hostPort); hostPort);
dwds = await dwdsFactory( dwds = await dwdsFactory(
hostname: hostname ?? _kHostName, hostname: effectiveHostname,
assetHandler: assetHandler, assetHandler: assetHandler,
buildResults: filteredBuildResults, buildResults: filteredBuildResults,
chromeConnection: () async { chromeConnection: () async {
...@@ -309,13 +310,13 @@ class WebFs { ...@@ -309,13 +310,13 @@ class WebFs {
Cascade cascade = Cascade(); Cascade cascade = Cascade();
cascade = cascade.add(handler); cascade = cascade.add(handler);
cascade = cascade.add(assetServer.handle); 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); shelf_io.serveRequests(server, cascade.handler);
final WebFs webFS = WebFs( final WebFs webFS = WebFs(
client, client,
server, server,
dwds, dwds,
'http://$_kHostName:$hostPort/', 'http://$effectiveHostname:$hostPort/',
assetServer, assetServer,
buildInfo.isDebug, buildInfo.isDebug,
flutterProject, flutterProject,
......
...@@ -167,7 +167,7 @@ void main() { ...@@ -167,7 +167,7 @@ void main() {
test('Uses provided port number and hostname.', () => testbed.run(() async { test('Uses provided port number and hostname.', () => testbed.run(() async {
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
await WebFs.start( final WebFs webFs = await WebFs.start(
skipDwds: false, skipDwds: false,
target: fs.path.join('lib', 'main.dart'), target: fs.path.join('lib', 'main.dart'),
buildInfo: BuildInfo.debug, buildInfo: BuildInfo.debug,
...@@ -177,6 +177,7 @@ void main() { ...@@ -177,6 +177,7 @@ void main() {
port: '1234', port: '1234',
); );
expect(webFs.uri, contains('foo:1234'));
expect(lastPort, 1234); expect(lastPort, 1234);
expect(lastAddress, contains('foo')); 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