OLD | NEW |
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 multipart_request; | 5 library multipart_request; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:math'; | 9 import 'dart:math'; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 "multipart requests."); | 66 "multipart requests."); |
67 } | 67 } |
68 | 68 |
69 /// The form fields to send for this request. | 69 /// The form fields to send for this request. |
70 final Map<String, String> fields; | 70 final Map<String, String> fields; |
71 | 71 |
72 /// The sink for files to upload for this request. | 72 /// The sink for files to upload for this request. |
73 /// | 73 /// |
74 /// This doesn't need to be closed. When the request is sent, whichever files | 74 /// This doesn't need to be closed. When the request is sent, whichever files |
75 /// are written to this sink at that point will be used. | 75 /// are written to this sink at that point will be used. |
76 StreamSink<MultipartFile> get files => _files; | 76 CollectionSink<MultipartFile> get files => _files; |
77 | 77 |
78 /// The private version of [files], typed so that the underlying collection is | 78 /// The private version of [files], typed so that the underlying collection is |
79 /// accessible. | 79 /// accessible. |
80 final CollectionSink<MultipartFile> _files; | 80 final CollectionSink<MultipartFile> _files; |
81 | 81 |
82 /// Creates a new [MultipartRequest]. | 82 /// Creates a new [MultipartRequest]. |
83 MultipartRequest(String method, Uri url) | 83 MultipartRequest(String method, Uri url) |
84 : super(method, url), | 84 : super(method, url), |
85 fields = {}, | 85 fields = {}, |
86 _files = new CollectionSink<MultipartFile>(<MultipartFile>[]); | 86 _files = new CollectionSink<MultipartFile>(<MultipartFile>[]); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 String _boundaryString(int length) { | 166 String _boundaryString(int length) { |
167 var prefix = "dart-http-boundary-"; | 167 var prefix = "dart-http-boundary-"; |
168 var list = new List<int>.fixedLength(length - prefix.length); | 168 var list = new List<int>.fixedLength(length - prefix.length); |
169 for (var i = 0; i < list.length; i++) { | 169 for (var i = 0; i < list.length; i++) { |
170 list[i] = _BOUNDARY_CHARACTERS[ | 170 list[i] = _BOUNDARY_CHARACTERS[ |
171 _random.nextInt(_BOUNDARY_CHARACTERS.length)]; | 171 _random.nextInt(_BOUNDARY_CHARACTERS.length)]; |
172 } | 172 } |
173 return "$prefix${new String.fromCharCodes(list)}"; | 173 return "$prefix${new String.fromCharCodes(list)}"; |
174 } | 174 } |
175 } | 175 } |
OLD | NEW |