Skip to content

Commit cf5ef1e

Browse files
authored
First assign the body to don't auto add the charset into 'Content-Type' header
This is a fix for `http` dependency issue, see dart-lang/http#1438
1 parent 3ad1276 commit cf5ef1e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/src/adapter/remote_adapter.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ mixin _RemoteAdapter<T extends DataModelMixin<T>> on _SerializationAdapter<T> {
359359

360360
try {
361361
final request = http.Request(method.toShortString(), uri & params);
362-
request.headers.addAll(headers);
363362

363+
// First assign the body to don't auto add the charset into 'Content-Type' header
364364
if (body != null) {
365365
if (body is String) {
366366
request.body = body;
@@ -372,6 +372,8 @@ mixin _RemoteAdapter<T extends DataModelMixin<T>> on _SerializationAdapter<T> {
372372
throw ArgumentError('Invalid request body "$body".');
373373
}
374374
}
375+
376+
request.headers.addAll(headers);
375377

376378
final stream = await httpClient.send(request);
377379
response = await http.Response.fromStream(stream);

0 commit comments

Comments
 (0)