HTTP response without content-length doesn't work

  • Thread starter Swamp Thing
  • Start date
  • #1
Swamp Thing
Insights Author
912
581
I am trying out the web server feature on a NodeMCU ESP8266 board. If I include a Content-Length line in the response header, it works perfectly.

But if I omit the content-length, then Chrome and Firefox fail to display the page. Chrome displays a blank page, and Firefox says "Connection was reset".

This is the HTTP response as received on Telnet:
Code:
HTTP/1.1 200 OK
Content-Type: text/html
Connection: close

<html><body>Hello</body></html>
Connection closed by foreign host.
(There is a "\r\n" at the end of each line and after the header).

Curl and Wget also report "connection closed" errors.

My understanding is that if content-length is not specified, then closing the connection is a valid way to signal end of data. Especially with "connection: close". So what is the problem?
 
Technology news on Phys.org
  • #2
  • Like
Likes Swamp Thing

Similar threads

  • Programming and Computer Science
Replies
1
Views
601
  • Programming and Computer Science
Replies
7
Views
3K
Replies
31
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Programming and Computer Science
Replies
6
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
12K
  • Computing and Technology
Replies
1
Views
7K
  • Computing and Technology
Replies
4
Views
3K
  • Special and General Relativity
3
Replies
75
Views
3K
Back
Top