'Flutter post request returns Unhandled Exception: HttpException: Connection closed before full header was received, uri
I'm facing some strange issue when try to make an http post request through HttpClient and through http package and for both I receive:
[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: HttpException: Connection closed before full header was received, uri = https://dumb.api.url/api/login
The strange thing is it works through postman, curl and if done natively on Android (Kotlin). Also, there is no VPN or whatever turned on.
I know there is a lot of similar questions, but none of them helped me.
I already tried using http package, HttpClient, ioClient, Dio to make a request. I also tried to set timeouts, use delays, using badCertificates callback, cleaning the project (flutter clean), restarting IDE and device and running this both on emulator and device.
Solution 1:[1]
From the logs provided, it looks like the request has timed out. Try creating a new Android virtual device with a different Android version or try wiping the data of the Android virtual device. This should help reset the network config of the device.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Omatt |
