Unhandled Exception: HttpException: Content-Length must contain only digits, uri = http://192.168.123.1/xyz.html
Unhandled Exception: HttpException: Content-Length must contain only digits, uri = http://192.168.200.1/AWIP.html
E/flutter ( 5783): #0 _HttpHeaders._addContentLength (dart:_http/http_headers.dart:383:9)
E/flutter ( 5783): #1 _HttpHeaders._add (dart:_http/http_headers.dart:359:11)
E/flutter ( 5783): #2 _HttpParser._doParse (dart:_http/http_parser.dart:725:23)
E/flutter ( 5783): #3 _HttpParser._parse (dart:_http/http_parser.dart:319:7)
E/flutter ( 5783): #4 _HttpParser._onData (dart:_http/http_parser.dart:873:5)
E/flutter ( 5783): #5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
E/flutter ( 5783): #6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter ( 5783): #7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter ( 5783): #8 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
E/flutter ( 5783): #9 _StreamController._add (dart:async/stream_controller.dart:648:7)
E/flutter ( 5783): #10 _StreamController.add (dart:async/stream_controller.dart:596:5)
E/flutter ( 5783): #11 _Socket._onData (dart:io-patch/socket_patch.dart:2355:41)
E/flutter ( 5783): #12 _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
E/flutter ( 5783): #13 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter ( 5783): #14 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter ( 5783): #15 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
E/flutter ( 5783): #16 _StreamController._add (dart:async/stream_controller.dart:648:7)
E/flutter ( 5783): #17 _StreamController.add (dart:async/stream_controller.dart:596:5)
E/flutter ( 5783): #18 new _RawSocket.
` static void dummyCall({required String url,required Map map}) async{ HttpClient client = HttpClient();
// Creating body here
List
HttpClientRequest request = await client.postUrl(Uri.parse(url));
request.headers.set('content-type', 'application/json');
log("CONTENT LENGTH ${body.length}");
request.headers.set('Accept', 'application/json');
// Setting the content-length header here request.headers.set('Content-Length', 17);
// Adding the body to the request log("HEADER ${request.headers.toString()}"); request.add(body);
HttpClientResponse response = await request.close();
log("RESPONSE ${response.statusCode}");
}`
What server is are you running this against? HttpClient does not correctly parse Content-Length headers containing extra whitespace.
i got the same error, i backward to flutter 3.3.4 and it run well. still have no idea
I I also encountered the same problem I use mongose server
The issue is caused by extra whitespace in the "Content-Length" header returned by the mongose service. The header looks something like this:
Content-Length: 43 \r\n Adding a trim operation would be better!
Thanks for the reproduction @menshen - we are working on this now.
This is a Dart issue and will be fixed in Dart 3.2.0