Repository: dart-lang/http (dart)

Issue:
`MediaType` is not exported to parent project
When I use `MultipartFile` constructors I could not specify the `contentType` property because `MediaType` from `http_parser` package is used internally in `multipart_file.dart` file and not exported into the target project.

Pull request:
This is a [similar change](https://github.com/cfug/dio/pull/2205) of which I introduced to the Dio package. A developer shouldn't have to import a transitive dependency (or make it a direct dependency) in order to use a method of a package.

Fixes #873

---

- [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR.

<details>
  <summary>Contribution guidelines:</summary><br>

- See our [contributor guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md) for general expectations for PRs.
- Larger or significant changes should be discussed in an issue before creating a PR.
- Contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`.
- Most changes should add an entry to the changelog and may need to [rev the pubspec package version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change).
- Changes to packages require [corresponding tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing).

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.
</details>

Patch:
diff --git a/pkgs/http/CHANGELOG.md b/pkgs/http/CHANGELOG.md
index 4c0c31af84..6d84d9c080 100644
--- a/pkgs/http/CHANGELOG.md
+++ b/pkgs/http/CHANGELOG.md
@@ -3,6 +3,7 @@
 * **Breaking** Change the behavior of `Request.body` so that a charset
   parameter is only added for text and XML media types. This brings the
   behavior of `package:http` in line with RFC-8259.
+* Export `MediaType` from `package:http_parser`.
 
 ## 1.5.0
 
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';


Test patch:
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<void> _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')