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

Side by Side Diff: pkg/http/lib/browser_client.dart

Issue 263313003: Fix an analyzer error in pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « pkg/http/CHANGELOG.md ('k') | pkg/http/pubspec.yaml » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library http.browser_client; 5 library http.browser_client;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:typed_data';
10 9
11 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
12 11
13 import 'src/base_client.dart'; 12 import 'src/base_client.dart';
14 import 'src/base_request.dart'; 13 import 'src/base_request.dart';
15 import 'src/byte_stream.dart'; 14 import 'src/byte_stream.dart';
16 import 'src/exception.dart'; 15 import 'src/exception.dart';
17 import 'src/streamed_response.dart'; 16 import 'src/streamed_response.dart';
18 17
19 // TODO(nweiz): Move this under src/, re-export from lib/http.dart, and use this 18 // TODO(nweiz): Move this under src/, re-export from lib/http.dart, and use this
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 completer.complete(new StreamedResponse( 58 completer.complete(new StreamedResponse(
60 new ByteStream.fromBytes(body), 59 new ByteStream.fromBytes(body),
61 xhr.status, 60 xhr.status,
62 contentLength: body.length, 61 contentLength: body.length,
63 request: request, 62 request: request,
64 headers: xhr.responseHeaders, 63 headers: xhr.responseHeaders,
65 reasonPhrase: xhr.statusText)); 64 reasonPhrase: xhr.statusText));
66 }); 65 });
67 66
68 reader.onError.first.then((error) { 67 reader.onError.first.then((error) {
69 completer.complete( 68 completer.completeError(
Bob Nystrom 2014/05/05 19:59:34 Oof. Oops.
nweiz 2014/05/05 20:00:14 Luckily I don't think this code path can actually
70 new ClientException(error.toString(), request.url), 69 new ClientException(error.toString(), request.url),
71 new Chain.current()); 70 new Chain.current());
72 }); 71 });
73 72
74 reader.readAsArrayBuffer(blob); 73 reader.readAsArrayBuffer(blob);
75 }); 74 });
76 75
77 xhr.onError.first.then((_) { 76 xhr.onError.first.then((_) {
78 // Unfortunately, the underlying XMLHttpRequest API doesn't expose any 77 // Unfortunately, the underlying XMLHttpRequest API doesn't expose any
79 // specific information about the error itself. 78 // specific information about the error itself.
80 completer.completeError( 79 completer.completeError(
81 new ClientException("XMLHttpRequest error.", request.url), 80 new ClientException("XMLHttpRequest error.", request.url),
82 new Chain.current()); 81 new Chain.current());
83 }); 82 });
84 83
85 xhr.send(bytes); 84 xhr.send(bytes);
86 return completer.future.whenComplete(() => _xhrs.remove(xhr)); 85 return completer.future.whenComplete(() => _xhrs.remove(xhr));
87 }); 86 });
88 } 87 }
89 88
90 /// Closes the client. 89 /// Closes the client.
91 /// 90 ///
92 /// This terminates all active requests. 91 /// This terminates all active requests.
93 void close() { 92 void close() {
94 for (var xhr in _xhrs) { 93 for (var xhr in _xhrs) {
95 xhr.abort(); 94 xhr.abort();
96 } 95 }
97 } 96 }
98 } 97 }
OLDNEW
« no previous file with comments | « pkg/http/CHANGELOG.md ('k') | pkg/http/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698