Skip to content

Commit 8b3b6e9

Browse files
authored
Merge pull request #100 from donny-dont/merge/0.11.x
Merge 0.11.x branch
2 parents f62d1a6 + 5098a28 commit 8b3b6e9

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 0.11.3+13
2+
3+
* remove boundary characters that package:http_parser cannot parse.
4+
5+
## 0.11.3+12
6+
7+
* Don't quote the boundary header for `MultipartRequest`. This is more
8+
compatible with server quirks.
9+
10+
## 0.11.3+11
11+
12+
* Fix the SDK constraint to only include SDK versions that support importing
13+
`dart:io` everywhere.
14+
115
## 0.11.3+10
216

317
* Stop using `dart:mirrors`.

lib/src/boundary_characters.dart

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// All character codes that are valid in multipart boundaries. This is the
6+
/// intersection of the characters allowed in the `bcharsnospace` production
7+
/// defined in [RFC 2046][] and those allowed in the `token` production
8+
/// defined in [RFC 1521][].
9+
///
10+
/// [RFC 2046]: http://tools.ietf.org/html/rfc2046#section-5.1.1.
11+
/// [RFC 1521]: https://tools.ietf.org/html/rfc1521#section-4
12+
const List<int> BOUNDARY_CHARACTERS = const <int>[
13+
39, 43, 95, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
14+
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
15+
84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
16+
107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
17+
122
18+
];

lib/src/multipart_request.dart

+3-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:convert';
77
import 'dart:math';
88

99
import 'base_request.dart';
10+
import 'boundary_characters.dart';
1011
import 'byte_stream.dart';
1112
import 'multipart_file.dart';
1213
import 'utils.dart';
@@ -83,7 +84,7 @@ class MultipartRequest extends BaseRequest {
8384
ByteStream finalize() {
8485
// TODO(nweiz): freeze fields and files
8586
var boundary = _boundaryString();
86-
headers['content-type'] = 'multipart/form-data; boundary="$boundary"';
87+
headers['content-type'] = 'multipart/form-data; boundary=$boundary';
8788
super.finalize();
8889

8990
var controller = new StreamController<List<int>>(sync: true);
@@ -117,16 +118,6 @@ class MultipartRequest extends BaseRequest {
117118
return new ByteStream(controller.stream);
118119
}
119120

120-
/// All character codes that are valid in multipart boundaries. From
121-
/// http://tools.ietf.org/html/rfc2046#section-5.1.1.
122-
static const List<int> _BOUNDARY_CHARACTERS = const <int>[
123-
39, 40, 41, 43, 95, 44, 45, 46, 47, 58, 61, 63, 48, 49, 50, 51, 52, 53, 54,
124-
55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
125-
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103,
126-
104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
127-
119, 120, 121, 122
128-
];
129-
130121
/// Returns the header string for a field. The return value is guaranteed to
131122
/// contain only ASCII characters.
132123
String _headerForField(String name, String value) {
@@ -167,7 +158,7 @@ class MultipartRequest extends BaseRequest {
167158
var prefix = "dart-http-boundary-";
168159
var list = new List<int>.generate(_BOUNDARY_LENGTH - prefix.length,
169160
(index) =>
170-
_BOUNDARY_CHARACTERS[_random.nextInt(_BOUNDARY_CHARACTERS.length)],
161+
BOUNDARY_CHARACTERS[_random.nextInt(BOUNDARY_CHARACTERS.length)],
171162
growable: false);
172163
return "$prefix${new String.fromCharCodes(list)}";
173164
}

lib/src/utils.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Uint8List toUint8List(List<int> input) {
9595
/// Calls [onDone] once [stream] (a single-subscription [Stream]) is finished.
9696
/// The return value, also a single-subscription [Stream] should be used in
9797
/// place of [stream] after calling this method.
98-
Stream/*<T>*/ onDone/*<T>*/(Stream/*<T>*/ stream, void onDone()) =>
98+
Stream<T> onDone<T>(Stream<T> stream, void onDone()) =>
9999
stream.transform(new StreamTransformer.fromHandlers(handleDone: (sink) {
100100
sink.close();
101101
onDone();

0 commit comments

Comments
 (0)