When trying to send a request with Request.bodyBytes set, I realized the request is given a conversion error as body rather than the actually provided body.
Minimal sample to reproduce :
import 'dart:convert';
import 'package:fetch_client/fetch_client.dart';
import 'package:http/http.dart';
Future<void> main() async {
final client = FetchClient(
mode: RequestMode.cors,
credentials: RequestCredentials.omit,
cache: RequestCache.noStore,
referrerPolicy: RequestReferrerPolicy.strictOriginWhenCrossOrigin,
streamRequests: true,
);
final request = Request(
'POST',
Uri.parse('https://example.com'),
);
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(jsonEncode({'test': 'foo'}));
final response = await client.send(request);
final responseBody = await response.stream.toBytes();
final responseString = utf8.decode(responseBody);
print(responseString);
}
When inspecting the request in the dev tools of my browser, the request body shows as :
Rather than the expected
I'd expect a fallback on non-streamed requests if the browser does not support them.
Environment:
Firefox 139.0.1 on Linux
When trying to send a request with
Request.bodyBytesset, I realized the request is given a conversion error as body rather than the actually provided body.Minimal sample to reproduce :
When inspecting the request in the dev tools of my browser, the request body shows as :
Rather than the expected
{"test":"foo"}I'd expect a fallback on non-streamed requests if the browser does not support them.
Environment:
Firefox 139.0.1 on Linux