diff --git a/pkgs/http/lib/http.dart b/pkgs/http/lib/http.dart index 31043f0e32..dda7fede3d 100644 --- a/pkgs/http/lib/http.dart +++ b/pkgs/http/lib/http.dart @@ -14,6 +14,8 @@ import 'src/request.dart'; import 'src/response.dart'; import 'src/streamed_request.dart'; +export 'package:http_parser/http_parser.dart' show MediaType; + export 'src/abortable.dart'; export 'src/base_client.dart'; export 'src/base_request.dart'; diff --git a/pkgs/http/test/multipart_test.dart b/pkgs/http/test/multipart_test.dart index 951e99017a..ef0fe85e77 100644 --- a/pkgs/http/test/multipart_test.dart +++ b/pkgs/http/test/multipart_test.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'package:http/http.dart' as http; import 'package:http/src/boundary_characters.dart'; -import 'package:http_parser/http_parser.dart'; import 'package:test/test.dart'; import 'utils.dart'; @@ -21,7 +20,8 @@ void main() { test('boundary characters', () { var testBoundary = String.fromCharCodes(boundaryCharacters); - var contentType = MediaType.parse('text/plain; boundary=$testBoundary'); + var contentType = + http.MediaType.parse('text/plain; boundary=$testBoundary'); var boundary = contentType.parameters['boundary']; expect(boundary, testBoundary); }); @@ -159,7 +159,7 @@ void main() { test('with a string file with a content-type but no charset', () { var request = http.MultipartRequest('POST', dummyUrl); var file = http.MultipartFile.fromString('file', '{"hello": "world"}', - contentType: MediaType('application', 'json')); + contentType: http.MediaType('application', 'json')); request.files.add(file); expect(request, bodyMatches(''' @@ -175,8 +175,11 @@ void main() { test('with a file with a iso-8859-1 body', () { var request = http.MultipartRequest('POST', dummyUrl); // "Ã¥" encoded as ISO-8859-1 and then read as UTF-8 results in "å". - var file = http.MultipartFile.fromString('file', 'non-ascii: "Ã¥"', - contentType: MediaType('text', 'plain', {'charset': 'iso-8859-1'})); + var file = http.MultipartFile.fromString( + 'file', + 'non-ascii: "Ã¥"', + contentType: http.MediaType('text', 'plain', {'charset': 'iso-8859-1'}), + ); request.files.add(file); expect(request, bodyMatches(''' diff --git a/pkgs/http/test/utils.dart b/pkgs/http/test/utils.dart index d4c319f73f..afa0b93067 100644 --- a/pkgs/http/test/utils.dart +++ b/pkgs/http/test/utils.dart @@ -5,7 +5,6 @@ import 'dart:convert'; import 'package:http/http.dart' as http; -import 'package:http_parser/http_parser.dart'; import 'package:test/test.dart'; /// A dummy URL for constructing requests that won't be sent. @@ -91,7 +90,7 @@ class _BodyMatches extends Matcher { Future _checks(http.MultipartRequest item) async { var bodyBytes = await item.finalize().toBytes(); var body = utf8.decode(bodyBytes); - var contentType = MediaType.parse(item.headers['content-type']!); + var contentType = http.MediaType.parse(item.headers['content-type']!); var boundary = contentType.parameters['boundary']!; var expected = cleanUpLiteral(_pattern) .replaceAll('\n', '\r\n')