Index: pkg/http/test/http_test.dart |
diff --git a/pkg/http/test/http_test.dart b/pkg/http/test/http_test.dart |
index c6a80f2b73506b54f27d0d736ec040c9a98ed84d..92a14fa447d9dea3d81df42f8f128d7cf4ef2e62 100644 |
--- a/pkg/http/test/http_test.dart |
+++ b/pkg/http/test/http_test.dart |
@@ -50,8 +50,82 @@ main() { |
expect(http.post(serverUrl, headers: { |
'X-Random-Header': 'Value', |
'X-Other-Header': 'Other Value', |
+ 'Content-Type': 'text/plain', |
+ 'User-Agent': 'Dart' |
+ }).then((response) { |
+ expect(response.statusCode, equals(200)); |
+ expect(response.body, parse(equals({ |
+ 'method': 'POST', |
+ 'path': '/', |
+ 'headers': { |
+ 'accept-encoding': ['gzip'], |
+ 'content-length': ['0'], |
+ 'content-type': ['text/plain'], |
+ 'user-agent': ['Dart'], |
+ 'x-random-header': ['Value'], |
+ 'x-other-header': ['Other Value'] |
+ } |
+ }))); |
+ }), completes); |
+ }), completes); |
+ }); |
+ |
+ test('post with string', () { |
+ expect(startServer().then((_) { |
+ expect(http.post(serverUrl, headers: { |
+ 'X-Random-Header': 'Value', |
+ 'X-Other-Header': 'Other Value', |
+ 'User-Agent': 'Dart' |
+ }, body: 'request body').then((response) { |
+ expect(response.statusCode, equals(200)); |
+ expect(response.body, parse(equals({ |
+ 'method': 'POST', |
+ 'path': '/', |
+ 'headers': { |
+ 'content-type': ['text/plain; charset=utf-8'], |
+ 'content-length': ['12'], |
+ 'accept-encoding': ['gzip'], |
+ 'user-agent': ['Dart'], |
+ 'x-random-header': ['Value'], |
+ 'x-other-header': ['Other Value'] |
+ }, |
+ 'body': 'request body' |
+ }))); |
+ }), completes); |
+ }), completes); |
+ }); |
+ |
+ test('post with bytes', () { |
+ expect(startServer().then((_) { |
+ expect(http.post(serverUrl, headers: { |
+ 'X-Random-Header': 'Value', |
+ 'X-Other-Header': 'Other Value', |
+ 'User-Agent': 'Dart' |
+ }, body: [104, 101, 108, 108, 111]).then((response) { |
+ expect(response.statusCode, equals(200)); |
+ expect(response.body, parse(equals({ |
+ 'method': 'POST', |
+ 'path': '/', |
+ 'headers': { |
+ 'content-length': ['5'], |
+ 'accept-encoding': ['gzip'], |
+ 'user-agent': ['Dart'], |
+ 'x-random-header': ['Value'], |
+ 'x-other-header': ['Other Value'] |
+ }, |
+ 'body': [104, 101, 108, 108, 111] |
+ }))); |
+ }), completes); |
+ }), completes); |
+ }); |
+ |
+ test('post with fields', () { |
+ expect(startServer().then((_) { |
+ expect(http.post(serverUrl, headers: { |
+ 'X-Random-Header': 'Value', |
+ 'X-Other-Header': 'Other Value', |
'User-Agent': 'Dart' |
- }, fields: { |
+ }, body: { |
'some-field': 'value', |
'other-field': 'other value' |
}).then((response) { |
@@ -75,9 +149,9 @@ main() { |
}), completes); |
}); |
- test('post without fields', () { |
+ test('put', () { |
expect(startServer().then((_) { |
- expect(http.post(serverUrl, headers: { |
+ expect(http.put(serverUrl, headers: { |
'X-Random-Header': 'Value', |
'X-Other-Header': 'Other Value', |
'Content-Type': 'text/plain', |
@@ -85,7 +159,7 @@ main() { |
}).then((response) { |
expect(response.statusCode, equals(200)); |
expect(response.body, parse(equals({ |
- 'method': 'POST', |
+ 'method': 'PUT', |
'path': '/', |
'headers': { |
'accept-encoding': ['gzip'], |
@@ -100,56 +174,80 @@ main() { |
}), completes); |
}); |
- test('put', () { |
+ test('put with string', () { |
expect(startServer().then((_) { |
expect(http.put(serverUrl, headers: { |
'X-Random-Header': 'Value', |
'X-Other-Header': 'Other Value', |
'User-Agent': 'Dart' |
- }, fields: { |
- 'some-field': 'value', |
- 'other-field': 'other value' |
- }).then((response) { |
+ }, body: 'request body').then((response) { |
expect(response.statusCode, equals(200)); |
expect(response.body, parse(equals({ |
'method': 'PUT', |
'path': '/', |
'headers': { |
- 'content-type': [ |
- 'application/x-www-form-urlencoded; charset=utf-8' |
- ], |
+ 'content-type': ['text/plain; charset=utf-8'], |
+ 'content-length': ['12'], |
'accept-encoding': ['gzip'], |
- 'content-length': ['40'], |
'user-agent': ['Dart'], |
'x-random-header': ['Value'], |
'x-other-header': ['Other Value'] |
}, |
- 'body': 'some-field=value&other-field=other+value' |
+ 'body': 'request body' |
}))); |
}), completes); |
}), completes); |
}); |
- test('put without fields', () { |
+ test('put with bytes', () { |
expect(startServer().then((_) { |
expect(http.put(serverUrl, headers: { |
'X-Random-Header': 'Value', |
'X-Other-Header': 'Other Value', |
- 'Content-Type': 'text/plain', |
'User-Agent': 'Dart' |
+ }, body: [104, 101, 108, 108, 111]).then((response) { |
+ expect(response.statusCode, equals(200)); |
+ expect(response.body, parse(equals({ |
+ 'method': 'PUT', |
+ 'path': '/', |
+ 'headers': { |
+ 'content-length': ['5'], |
+ 'accept-encoding': ['gzip'], |
+ 'user-agent': ['Dart'], |
+ 'x-random-header': ['Value'], |
+ 'x-other-header': ['Other Value'] |
+ }, |
+ 'body': [104, 101, 108, 108, 111] |
+ }))); |
+ }), completes); |
+ }), completes); |
+ }); |
+ |
+ test('put with fields', () { |
+ expect(startServer().then((_) { |
+ expect(http.put(serverUrl, headers: { |
+ 'X-Random-Header': 'Value', |
+ 'X-Other-Header': 'Other Value', |
+ 'User-Agent': 'Dart' |
+ }, body: { |
+ 'some-field': 'value', |
+ 'other-field': 'other value' |
}).then((response) { |
expect(response.statusCode, equals(200)); |
expect(response.body, parse(equals({ |
'method': 'PUT', |
'path': '/', |
'headers': { |
- 'content-length': ['0'], |
+ 'content-type': [ |
+ 'application/x-www-form-urlencoded; charset=utf-8' |
+ ], |
+ 'content-length': ['40'], |
'accept-encoding': ['gzip'], |
- 'content-type': ['text/plain'], |
'user-agent': ['Dart'], |
'x-random-header': ['Value'], |
'x-other-header': ['Other Value'] |
- } |
+ }, |
+ 'body': 'some-field=value&other-field=other+value' |
}))); |
}), completes); |
}), completes); |