Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/http/lib/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
13 changes: 8 additions & 5 deletions pkgs/http/test/multipart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
});
Expand Down Expand Up @@ -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('''
Expand All @@ -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('''
Expand Down
3 changes: 1 addition & 2 deletions pkgs/http/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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')
Expand Down