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
b07d55d1
Commit
b07d55d1
authored
Nov 17, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant fetch functions and avoid crashing when no headers are set
parent
3350c0c3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
31 deletions
+9
-31
stock_data.dart
examples/stocks/lib/stock_data.dart
+3
-3
mojo_client.dart
packages/flutter/lib/src/http/mojo_client.dart
+1
-1
asset_bundle.dart
packages/flutter/lib/src/services/asset_bundle.dart
+3
-1
fetch.dart
packages/flutter/lib/src/services/fetch.dart
+0
-25
main.dart
packages/updater/lib/main.dart
+2
-1
No files found.
examples/stocks/lib/stock_data.dart
View file @
b07d55d1
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
import
'dart:convert'
;
import
'dart:convert'
;
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
import
'package:flutter/
services.dart'
;
import
'package:flutter/
http.dart'
as
http
;
final
math
.
Random
_rng
=
new
math
.
Random
();
final
math
.
Random
_rng
=
new
math
.
Random
();
...
@@ -83,8 +83,8 @@ class StockDataFetcher {
...
@@ -83,8 +83,8 @@ class StockDataFetcher {
if
(!
actuallyFetchData
)
if
(!
actuallyFetchData
)
return
;
return
;
fetchBody
(
_urlToFetch
(
_nextChunk
++)).
then
((
Response
response
)
{
http
.
get
(
_urlToFetch
(
_nextChunk
++)).
then
((
http
.
Response
response
)
{
String
json
=
response
.
body
AsString
()
;
String
json
=
response
.
body
;
if
(
json
==
null
)
{
if
(
json
==
null
)
{
print
(
"Failed to load stock data chunk
${_nextChunk - 1}
"
);
print
(
"Failed to load stock data chunk
${_nextChunk - 1}
"
);
return
;
return
;
...
...
packages/flutter/lib/src/http/mojo_client.dart
View file @
b07d55d1
...
@@ -66,7 +66,7 @@ class MojoClient {
...
@@ -66,7 +66,7 @@ class MojoClient {
Map
<
String
,
String
>
headers
,
[
body
,
Encoding
encoding
])
async
{
Map
<
String
,
String
>
headers
,
[
body
,
Encoding
encoding
])
async
{
mojo
.
UrlLoaderProxy
loader
=
new
mojo
.
UrlLoaderProxy
.
unbound
();
mojo
.
UrlLoaderProxy
loader
=
new
mojo
.
UrlLoaderProxy
.
unbound
();
List
<
mojo
.
HttpHeader
>
mojoHeaders
=
<
mojo
.
HttpHeader
>[];
List
<
mojo
.
HttpHeader
>
mojoHeaders
=
<
mojo
.
HttpHeader
>[];
headers
.
forEach
((
String
name
,
String
value
)
{
headers
?
.
forEach
((
String
name
,
String
value
)
{
mojo
.
HttpHeader
header
=
new
mojo
.
HttpHeader
()
mojo
.
HttpHeader
header
=
new
mojo
.
HttpHeader
()
..
name
=
name
..
name
=
name
..
value
=
value
;
..
value
=
value
;
...
...
packages/flutter/lib/src/services/asset_bundle.dart
View file @
b07d55d1
...
@@ -7,6 +7,8 @@ import 'dart:ui' as ui;
...
@@ -7,6 +7,8 @@ import 'dart:ui' as ui;
import
'dart:ui_internals'
as
internals
;
import
'dart:ui_internals'
as
internals
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'package:flutter/http.dart'
as
http
;
import
'package:mojo/core.dart'
as
core
;
import
'package:mojo/core.dart'
as
core
;
import
'package:mojo_services/mojo/asset_bundle/asset_bundle.mojom.dart'
;
import
'package:mojo_services/mojo/asset_bundle/asset_bundle.mojom.dart'
;
...
@@ -38,7 +40,7 @@ class NetworkAssetBundle extends AssetBundle {
...
@@ -38,7 +40,7 @@ class NetworkAssetBundle extends AssetBundle {
ImageResource
loadImage
(
String
key
)
=>
imageCache
.
load
(
_urlFromKey
(
key
));
ImageResource
loadImage
(
String
key
)
=>
imageCache
.
load
(
_urlFromKey
(
key
));
Future
<
String
>
loadString
(
String
key
)
=>
fetchString
(
_urlFromKey
(
key
));
Future
<
String
>
loadString
(
String
key
)
=>
http
.
get
(
_urlFromKey
(
key
));
}
}
Future
_fetchAndUnpackBundle
(
String
relativeUrl
,
AssetBundleProxy
bundle
)
async
{
Future
_fetchAndUnpackBundle
(
String
relativeUrl
,
AssetBundleProxy
bundle
)
async
{
...
...
packages/flutter/lib/src/services/fetch.dart
View file @
b07d55d1
...
@@ -23,18 +23,6 @@ NetworkServiceProxy _initNetworkService() {
...
@@ -23,18 +23,6 @@ NetworkServiceProxy _initNetworkService() {
final
NetworkServiceProxy
_networkService
=
_initNetworkService
();
final
NetworkServiceProxy
_networkService
=
_initNetworkService
();
class
Response
{
ByteData
body
;
Response
(
this
.
body
);
String
bodyAsString
()
{
if
(
body
==
null
)
return
null
;
return
new
String
.
fromCharCodes
(
new
Uint8List
.
view
(
body
.
buffer
));
}
}
Future
<
UrlResponse
>
fetch
(
UrlRequest
request
)
async
{
Future
<
UrlResponse
>
fetch
(
UrlRequest
request
)
async
{
UrlLoaderProxy
loader
=
new
UrlLoaderProxy
.
unbound
();
UrlLoaderProxy
loader
=
new
UrlLoaderProxy
.
unbound
();
try
{
try
{
...
@@ -56,16 +44,3 @@ Future<UrlResponse> fetchUrl(String relativeUrl) {
...
@@ -56,16 +44,3 @@ Future<UrlResponse> fetchUrl(String relativeUrl) {
..
autoFollowRedirects
=
true
;
..
autoFollowRedirects
=
true
;
return
fetch
(
request
);
return
fetch
(
request
);
}
}
Future
<
Response
>
fetchBody
(
String
relativeUrl
)
async
{
UrlResponse
response
=
await
fetchUrl
(
relativeUrl
);
if
(
response
.
body
==
null
)
return
new
Response
(
null
);
ByteData
data
=
await
core
.
DataPipeDrainer
.
drainHandle
(
response
.
body
);
return
new
Response
(
data
);
}
Future
<
String
>
fetchString
(
String
relativeUrl
)
async
{
Response
response
=
await
fetchBody
(
relativeUrl
);
return
response
.
bodyAsString
();
}
packages/updater/lib/main.dart
View file @
b07d55d1
...
@@ -6,6 +6,7 @@ import 'dart:async';
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'dart:io'
;
import
'dart:io'
;
import
'package:mojo/core.dart'
;
import
'package:mojo/core.dart'
;
import
'package:flutter/http.dart'
as
http
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flx/bundle.dart'
;
import
'package:flx/bundle.dart'
;
import
'package:sky_services/updater/update_service.mojom.dart'
;
import
'package:sky_services/updater/update_service.mojom.dart'
;
...
@@ -82,7 +83,7 @@ class UpdateTask {
...
@@ -82,7 +83,7 @@ class UpdateTask {
Future
<
yaml
.
YamlMap
>
_fetchManifest
()
async
{
Future
<
yaml
.
YamlMap
>
_fetchManifest
()
async
{
String
manifestUrl
=
_currentManifest
[
'update-url'
]
+
'/'
+
kManifestFile
;
String
manifestUrl
=
_currentManifest
[
'update-url'
]
+
'/'
+
kManifestFile
;
String
manifestData
=
await
fetchString
(
manifestUrl
);
String
manifestData
=
await
http
.
get
(
manifestUrl
);
return
yaml
.
loadYaml
(
manifestData
,
sourceUrl:
manifestUrl
);
return
yaml
.
loadYaml
(
manifestData
,
sourceUrl:
manifestUrl
);
}
}
...
...
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