-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
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 :
[object ReadableStream]
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels