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

Side by Side Diff: pkg/http/lib/src/stream_request.dart

Issue 11338054: Add an HTTP library that wraps dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
OLDNEW
(Empty)
1 library stream_request;
2
3 import 'dart:io';
4 import 'dart:uri';
5
6 import 'base_request.dart';
7
8 /// An HTTP request where the request body is sent asynchronously after the
9 /// connection has been established and the headers have been sent.
10 ///
11 /// When the request is sent via [BaseClient.send], only the headers and
12 /// whatever data has already been written to [StreamRequest.stream] will be
13 /// sent immediately. More data will be sent as soon as it's written to
14 /// [StreamRequest.stream], and when the stream is closed the request will be
15 /// ended.
Bob Nystrom 2012/10/31 01:17:44 "will be ended" -> "will end".
nweiz 2012/10/31 18:20:59 Done.
16 class StreamRequest extends BaseRequest {
Bob Nystrom 2012/10/31 01:17:44 This reads like a request for a stream and not a r
nweiz 2012/10/31 18:20:59 Done.
17 /// The stream to which to write data that will be sent as the request body.
18 /// This may be safely written to before the request is sent; the data will be
19 /// buffered.
20 ///
21 /// Closing this signals the end of the request.
22 final OutputStream stream;
23
24 /// The stream from which the [BaseClient] will read the data in [stream] once
25 /// the request has been finalized.
26 final ListInputStream _inputStream;
27
28 /// Create a new streaming request.
29 StreamRequest(String method, Uri url)
30 : super(method, url),
31 stream = new ListOutputStream(),
32 _inputStream = new ListInputStream() {
33 // TODO(nweiz): pipe errors from the output stream to the input stream once
34 // issue 3657 is fixed
35 stream.onData = () => _inputStream.write(stream.read());
36 stream.onClosed = _inputStream.markEndOfStream;
37 }
38
39 /// Freeze all mutable fields other than [stream] and return an [InputStream]
40 /// that emits the data being written to [stream].
41 InputStream finalize() {
42 super.finalize();
43 return _inputStream;
44 }
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698