Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Side by Side Diff: lib/src/barback/barback_server.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/barback/asset_environment.dart ('k') | lib/src/barback/cycle_exception.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'package:async/async.dart';
8 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
9 import 'package:mime/mime.dart'; 10 import 'package:mime/mime.dart';
10 import 'package:path/path.dart' as path; 11 import 'package:path/path.dart' as path;
11 import 'package:shelf/shelf.dart' as shelf; 12 import 'package:shelf/shelf.dart' as shelf;
12 import 'package:stack_trace/stack_trace.dart'; 13 import 'package:stack_trace/stack_trace.dart';
13 14
14 import '../barback.dart'; 15 import '../barback.dart';
15 import '../io.dart'; 16 import '../io.dart';
16 import '../log.dart' as log; 17 import '../log.dart' as log;
17 import '../utils.dart'; 18 import '../utils.dart';
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // "pub serve" is only used as a development server and doesn't require 150 // "pub serve" is only used as a development server and doesn't require
150 // any sort of credentials anyway, this is secure. 151 // any sort of credentials anyway, this is secure.
151 return response.change( 152 return response.change(
152 headers: const {"Access-Control-Allow-Origin": "*"}); 153 headers: const {"Access-Control-Allow-Origin": "*"});
153 }); 154 });
154 } 155 }
155 156
156 /// Returns the body of [asset] as a response to [request]. 157 /// Returns the body of [asset] as a response to [request].
157 Future<shelf.Response> _serveAsset(shelf.Request request, Asset asset) async { 158 Future<shelf.Response> _serveAsset(shelf.Request request, Asset asset) async {
158 try { 159 try {
159 var pair = tee(await validateStream(asset.read())); 160 var streams = StreamSplitter.splitFrom(
160 var responseStream = pair.first; 161 await validateStream(asset.read()));
161 var hashStream = pair.last; 162 var responseStream = streams.first;
163 var hashStream = streams.last;
162 164
163 // Allow the asset to be cached based on its content hash. 165 // Allow the asset to be cached based on its content hash.
164 var assetSha = await sha1Stream(hashStream); 166 var assetSha = await sha1Stream(hashStream);
165 var previousSha = request.headers["if-none-match"]; 167 var previousSha = request.headers["if-none-match"];
166 168
167 var headers = { 169 var headers = {
168 // Enable browser caching of the asset. 170 // Enable browser caching of the asset.
169 "ETag": assetSha 171 "ETag": assetSha
170 }; 172 };
171 173
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 : error = null, 230 : error = null,
229 isCached = false; 231 isCached = false;
230 232
231 BarbackServerResult._cached(this.url, this.id) 233 BarbackServerResult._cached(this.url, this.id)
232 : error = null, 234 : error = null,
233 isCached = true; 235 isCached = true;
234 236
235 BarbackServerResult._failure(this.url, this.id, this.error) 237 BarbackServerResult._failure(this.url, this.id, this.error)
236 : isCached = false; 238 : isCached = false;
237 } 239 }
OLDNEW
« no previous file with comments | « lib/src/barback/asset_environment.dart ('k') | lib/src/barback/cycle_exception.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698