Search code examples
flutterdartesp8266arduino-esp8266

The Content-Length header occurred more than once, at most one is allowed


when i try to connect over the following link:

http://192.168.4.1/wifisave?s=asdasd&p=10001010101010&ip=192.168.1.202&gw=192.168.1.1&sn=255.255.255.0&[email protected]&pass=123456789&alarm=1

I get the following error

The Content-Length header occurred more than once, at most one is allowed.

even though normal link like

http://192.168.1.200/anything

do works,

even thought it was working before, I don't know if the upgrade of the latest version of the library did affect that, tried to downgrade but I can't due to null-saftey restrictions and other depandancies.. the line of code:

try {
String overAllLink='http://192.168.4.1/wifisave?s=asdasd&p=10001010101010&ip=192.168.1.202&gw=192.168.1.1&sn=255.255.255.0&[email protected]&pass=123456789&alarm=1';
    response = await http.get(Uri.parse(overAllLink));
  } catch (e) {
    print(e);
  }

EDIT: server response when I try to from an API tester is

> Host: 192.168.4.1
> User-Agent: insomnia/2021.2.2
> Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
> Accept: */*
> Content-Length: 25

| --X-INSOMNIA-BOUNDARY--

* We are completely uploaded and fine
* Mark bundle as not supporting multiuse

< HTTP/1.1 200 OK
< Content-Type: text/html
< Content-Length: 1210
< Content-Length: 1210 //second one.
< Connection: close

so the server appears to send the Content-Length twice, so how can I ignore this or solve it, my server is ESP8266 with WiFiManger .16 library installed.


Solution

  • Alright, the problem was with my ESP8266 server, it was sending the Content-Length twice by mistake as mentioned in the question, opening an issue here to mention that did solve the problem thanks to the library owner.