File tree Expand file tree Collapse file tree 6 files changed +19
-11
lines changed Expand file tree Collapse file tree 6 files changed +19
-11
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.13.2-dev
2
+
1
3
## 0.13.1
2
4
3
5
* Fix code samples in ` README ` to pass a ` Uri ` instance.
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ linter:
12
12
- avoid_bool_literals_in_conditional_expressions
13
13
- avoid_catching_errors
14
14
- avoid_classes_with_only_static_members
15
+ - avoid_dynamic_calls
15
16
- avoid_empty_else
16
17
- avoid_function_literals_in_foreach_calls
17
18
- avoid_init_to_null
Original file line number Diff line number Diff line change 1
1
import 'dart:convert' as convert;
2
+
2
3
import 'package:http/http.dart' as http;
3
4
4
5
void main (List <String > arguments) async {
@@ -10,7 +11,8 @@ void main(List<String> arguments) async {
10
11
// Await the http get response, then decode the json-formatted response.
11
12
var response = await http.get (url);
12
13
if (response.statusCode == 200 ) {
13
- var jsonResponse = convert.jsonDecode (response.body);
14
+ var jsonResponse =
15
+ convert.jsonDecode (response.body) as Map <String , dynamic >;
14
16
var itemCount = jsonResponse['totalItems' ];
15
17
print ('Number of books about http: $itemCount .' );
16
18
} else {
Original file line number Diff line number Diff line change 1
1
name : http
2
- version : 0.13.1
2
+ version : 0.13.2-dev
3
3
homepage : https://github.com/dart-lang/http
4
4
description : A composable, multi-platform, Future-based API for HTTP requests.
5
5
Original file line number Diff line number Diff line change 3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
5
@TestOn ('vm' )
6
-
7
6
import 'dart:convert' ;
8
7
import 'dart:io' ;
9
8
@@ -117,7 +116,8 @@ void main() {
117
116
var bytesString = await response.stream.bytesToString ();
118
117
client.close ();
119
118
120
- var headers = jsonDecode (bytesString)['headers' ] as Map <String , dynamic >;
119
+ var headers = (jsonDecode (bytesString) as Map <String , dynamic >)['headers' ]
120
+ as Map <String , dynamic >;
121
121
var contentType = (headers['content-type' ] as List ).single;
122
122
expect (contentType, startsWith ('multipart/form-data; boundary=' ));
123
123
});
Original file line number Diff line number Diff line change @@ -83,20 +83,23 @@ Future<void> startServer() async {
83
83
requestBody = requestBodyBytes;
84
84
}
85
85
86
- var content = < String , dynamic > {
87
- 'method' : request.method,
88
- 'path' : request.uri.path,
89
- 'headers' : {}
90
- };
91
- if (requestBody != null ) content['body' ] = requestBody;
86
+ final headers = < String , List <String >> {};
87
+
92
88
request.headers.forEach ((name, values) {
93
89
// These headers are automatically generated by dart:io, so we don't
94
90
// want to test them here.
95
91
if (name == 'cookie' || name == 'host' ) return ;
96
92
97
- content[ ' headers' ] [name] = values;
93
+ headers[name] = values;
98
94
});
99
95
96
+ var content = < String , dynamic > {
97
+ 'method' : request.method,
98
+ 'path' : request.uri.path,
99
+ if (requestBody != null ) 'body' : requestBody,
100
+ 'headers' : headers,
101
+ };
102
+
100
103
var body = json.encode (content);
101
104
response
102
105
..contentLength = body.length
You can’t perform that action at this time.
0 commit comments