Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e340c199
Commit
e340c199
authored
Jan 21, 2020
by
Jonah Williams
Committed by
Flutter GitHub Bot
Jan 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] resolve host address in the flutter tool for web server (#48992)
parent
da0bfd1c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
15 deletions
+26
-15
resident_web_runner.dart
...utter_tools/lib/src/build_runner/resident_web_runner.dart
+2
-2
web_fs.dart
packages/flutter_tools/lib/src/build_runner/web_fs.dart
+6
-2
devfs_web.dart
packages/flutter_tools/lib/src/web/devfs_web.dart
+12
-4
devfs_web_test.dart
.../flutter_tools/test/general.shard/web/devfs_web_test.dart
+1
-1
web_fs_test.dart
...ges/flutter_tools/test/general.shard/web/web_fs_test.dart
+5
-6
No files found.
packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
View file @
e340c199
...
...
@@ -402,7 +402,7 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner {
hostPort
,
packagesFilePath
,
);
await
device
.
devFS
.
create
();
final
Uri
url
=
await
device
.
devFS
.
create
();
await
_updateDevFS
(
fullRestart:
true
);
device
.
generator
.
accept
();
await
device
.
device
.
startApp
(
...
...
@@ -410,7 +410,7 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner {
mainPath:
target
,
debuggingOptions:
debuggingOptions
,
platformArgs:
<
String
,
Object
>{
'uri'
:
'http://
$effectiveHostname
:
$hostPort
'
,
'uri'
:
url
.
toString
()
,
},
);
return
attach
(
...
...
packages/flutter_tools/lib/src/build_runner/web_fs.dart
View file @
e340c199
...
...
@@ -333,13 +333,17 @@ class WebFs {
Cascade
cascade
=
Cascade
();
cascade
=
cascade
.
add
(
handler
);
cascade
=
cascade
.
add
(
assetServer
.
handle
);
final
HttpServer
server
=
await
httpMultiServerFactory
(
effectiveHostname
,
hostPort
);
final
InternetAddress
internetAddress
=
(
await
InternetAddress
.
lookup
(
effectiveHostname
)).
first
;
final
HttpServer
server
=
await
httpMultiServerFactory
(
internetAddress
,
hostPort
);
shelf_io
.
serveRequests
(
server
,
cascade
.
handler
);
final
WebFs
webFS
=
WebFs
(
client
,
server
,
dwds
,
'http://
$effectiveHostname
:
$hostPort
/'
,
// Format ipv6 hosts according to RFC 5952.
internetAddress
.
type
==
InternetAddressType
.
IPv4
?
'
${internetAddress.address}
:
$hostPort
'
:
'[
${internetAddress.address}
]:
$hostPort
'
,
assetServer
,
buildInfo
.
isDebug
,
flutterProject
,
...
...
packages/flutter_tools/lib/src/web/devfs_web.dart
View file @
e340c199
...
...
@@ -28,7 +28,7 @@ import 'bootstrap.dart';
/// This is only used in development mode.
class
WebAssetServer
{
@visibleForTesting
WebAssetServer
(
this
.
_httpServer
,
this
.
_packages
,
WebAssetServer
(
this
.
_httpServer
,
this
.
_packages
,
this
.
internetAddress
,
{
@required
void
Function
(
dynamic
,
StackTrace
)
onError
})
{
_httpServer
.
listen
((
HttpRequest
request
)
{
_handleRequest
(
request
).
catchError
(
onError
);
...
...
@@ -46,10 +46,11 @@ class WebAssetServer {
/// trace.
static
Future
<
WebAssetServer
>
start
(
String
hostname
,
int
port
)
async
{
try
{
final
HttpServer
httpServer
=
await
HttpServer
.
bind
(
hostname
,
port
);
final
InternetAddress
address
=
(
await
InternetAddress
.
lookup
(
hostname
)).
first
;
final
HttpServer
httpServer
=
await
HttpServer
.
bind
(
address
,
port
);
final
Packages
packages
=
await
loadPackagesFile
(
Uri
.
base
.
resolve
(
'.packages'
));
return
WebAssetServer
(
httpServer
,
packages
,
return
WebAssetServer
(
httpServer
,
packages
,
address
,
onError:
(
dynamic
error
,
StackTrace
stackTrace
)
{
httpServer
.
close
(
force:
true
);
throwToolExit
(
...
...
@@ -71,6 +72,7 @@ class WebAssetServer {
final
RegExp
_drivePath
=
RegExp
(
r'\/[A-Z]:\/'
);
final
Packages
_packages
;
final
InternetAddress
internetAddress
;
// handle requests for JavaScript source, dart sources maps, or asset files.
Future
<
void
>
_handleRequest
(
HttpRequest
request
)
async
{
...
...
@@ -274,7 +276,13 @@ class WebDevFS implements DevFS {
@override
Future
<
Uri
>
create
()
async
{
_webAssetServer
=
await
WebAssetServer
.
start
(
hostname
,
port
);
return
Uri
.
base
;
final
InternetAddress
internetAddress
=
_webAssetServer
.
internetAddress
;
// Format ipv6 hosts according to RFC 5952.
return
Uri
.
parse
(
internetAddress
.
type
==
InternetAddressType
.
IPv4
?
'
${internetAddress.address}
:
$port
'
:
'[
${internetAddress.address}
]:
$port
'
);
}
@override
...
...
packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
View file @
e340c199
...
...
@@ -68,7 +68,7 @@ void main() {
closeCompleter
.
complete
();
});
webAssetServer
=
WebAssetServer
(
mockHttpServer
,
packages
,
onError:
(
dynamic
error
,
StackTrace
stackTrace
)
{
mockHttpServer
,
packages
,
InternetAddress
.
loopbackIPv4
,
onError:
(
dynamic
error
,
StackTrace
stackTrace
)
{
closeCompleter
.
completeError
(
error
,
stackTrace
);
});
});
...
...
packages/flutter_tools/test/general.shard/web/web_fs_test.dart
View file @
e340c199
...
...
@@ -32,11 +32,9 @@ void main() {
MockOperatingSystemUtils
mockOperatingSystemUtils
;
MockProcessUtils
mockProcessUtils
;
bool
lastInitializePlatform
;
dynamic
lastAddress
;
int
lastPort
;
setUp
(()
{
lastAddress
=
null
;
lastPort
=
null
;
lastInitializePlatform
=
null
;
mockBuildDaemonCreator
=
MockBuildDaemonCreator
();
...
...
@@ -95,7 +93,6 @@ void main() {
ChromeLauncher:
()
=>
mockChromeLauncher
,
ProcessUtils:
()
=>
mockProcessUtils
,
HttpMultiServerFactory:
()
=>
(
dynamic
address
,
int
port
)
async
{
lastAddress
=
address
;
lastPort
=
port
;
return
mockHttpMultiServer
;
},
...
...
@@ -178,15 +175,17 @@ void main() {
buildInfo:
BuildInfo
.
debug
,
flutterProject:
flutterProject
,
initializePlatform:
false
,
hostname:
'
foo
'
,
hostname:
'
localhost
'
,
port:
'1234'
,
urlTunneller:
null
,
dartDefines:
const
<
String
>[],
);
expect
(
webFs
.
uri
,
contains
(
'foo:1234'
));
// Might be either ipv4 or ipv6 for localhost.
final
bool
hasExpectedUri
=
webFs
.
uri
.
toString
().
contains
(
'[::1]:1234'
)
||
webFs
.
uri
.
toString
().
contains
(
'127.0.0.1:1234'
);
expect
(
hasExpectedUri
,
true
);
expect
(
lastPort
,
1234
);
expect
(
lastAddress
,
contains
(
'foo'
));
}));
test
(
'Throws exception if build fails'
,
()
=>
testbed
.
run
(()
async
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment