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
bbf913bc
Unverified
Commit
bbf913bc
authored
Mar 05, 2020
by
Jonah Williams
Committed by
GitHub
Mar 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] resolve requests to web directory in debug mode (#51995)
parent
374f85c9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
1 deletion
+48
-1
test.dart
dev/bots/test.dart
+1
-0
web_directory_loading.dart
dev/integration_tests/web/lib/web_directory_loading.dart
+24
-0
example
dev/integration_tests/web/web/example
+1
-0
devfs_web.dart
packages/flutter_tools/lib/src/build_runner/devfs_web.dart
+7
-1
devfs_web_test.dart
.../flutter_tools/test/general.shard/web/devfs_web_test.dart
+15
-0
No files found.
dev/bots/test.dart
View file @
bbf913bc
...
...
@@ -588,6 +588,7 @@ Future<void> _runWebIntegrationTests() async {
await
_runWebStackTraceTest
(
'profile'
);
await
_runWebStackTraceTest
(
'release'
);
await
_runWebDebugTest
(
'lib/stack_trace.dart'
);
await
_runWebDebugTest
(
'lib/web_directory_loading.dart'
);
await
_runWebDebugTest
(
'test/test.dart'
);
}
...
...
dev/integration_tests/web/lib/web_directory_loading.dart
0 → 100644
View file @
bbf913bc
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:html'
as
html
;
// Attempt to load a file that is hosted in the applications's `web/` directory.
Future
<
void
>
main
()
async
{
try
{
final
html
.
HttpRequest
request
=
await
html
.
HttpRequest
.
request
(
'/example'
,
method:
'GET'
,
);
final
String
body
=
request
.
responseText
;
if
(
body
==
'This is an Example'
)
{
print
(
'--- TEST SUCCEEDED ---'
);
}
else
{
print
(
'--- TEST FAILED ---'
);
}
}
catch
(
err
)
{
print
(
err
);
print
(
'--- TEST FAILED ---'
);
}
}
dev/integration_tests/web/web/example
0 → 100644
View file @
bbf913bc
This is an Example
\ No newline at end of file
packages/flutter_tools/lib/src/build_runner/devfs_web.dart
View file @
bbf913bc
...
...
@@ -190,10 +190,16 @@ class WebAssetServer implements AssetReader {
// Try and resolve the path relative to the built asset directory.
if
(!
file
.
existsSync
())
{
final
Uri
potential
=
globals
.
fs
.
directory
(
getAssetBuildDirectory
())
.
uri
.
resolve
(
requestPath
.
replaceFirst
(
'/assets/'
,
''
));
.
uri
.
resolve
(
requestPath
.
replaceFirst
(
'/assets/'
,
''
));
file
=
globals
.
fs
.
file
(
potential
);
}
if
(!
file
.
existsSync
())
{
final
String
webPath
=
globals
.
fs
.
path
.
join
(
globals
.
fs
.
currentDirectory
.
childDirectory
(
'web'
).
path
,
requestPath
.
substring
(
1
));
file
=
globals
.
fs
.
file
(
webPath
);
}
if
(!
file
.
existsSync
())
{
return
shelf
.
Response
.
notFound
(
''
);
}
...
...
packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
View file @
bbf913bc
...
...
@@ -191,6 +191,21 @@ void main() {
]));
expect
((
await
response
.
read
().
toList
()).
first
,
source
.
readAsBytesSync
());
}));
test
(
'serves files from web directory'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'foo.png'
))
..
createSync
(
recursive:
true
)
..
writeAsBytesSync
(
kTransparentImage
);
final
Response
response
=
await
webAssetServer
.
handleRequest
(
Request
(
'GET'
,
Uri
.
parse
(
'http://foobar/foo.png'
)));
expect
(
response
.
headers
,
allOf
(<
Matcher
>[
containsPair
(
HttpHeaders
.
contentLengthHeader
,
source
.
lengthSync
().
toString
()),
containsPair
(
HttpHeaders
.
contentTypeHeader
,
'image/png'
),
containsPair
(
HttpHeaders
.
etagHeader
,
isNotNull
),
containsPair
(
HttpHeaders
.
cacheControlHeader
,
'max-age=0, must-revalidate'
)
]));
expect
((
await
response
.
read
().
toList
()).
first
,
source
.
readAsBytesSync
());
}));
test
(
'serves asset files from in filesystem with known mime type on Windows'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'flutter_assets'
,
'foo.png'
))
...
...
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