How to remove content-length header from http GET request in Flutter?

Viewed 1077

I try to create a Flutter client app that communicates to REST API. When I create an HTTP GET request as below, it always includes content-length:0 and the server returns status code 400:Bad request. If I send a request without this header by another tool, server returns status code 200:OK.

//import 'package:http/http.dart' as http;
final client = http.Client();
final response = await client.get(url);

or

//import 'package:dio/dio.dart';
final options = BaseOptions();
options.headers.remove(Headers.contentTypeHeader);
options.headers.remove(Headers.contentLengthHeader);
final dio = Dio(options);
final response = await dio.get(url);

How can I remove this header?

0 Answers
Related