HTTP response without content-length doesn't work

  • Thread starter Thread starter Swamp Thing
  • Start date Start date
AI Thread Summary
When using the web server feature on a NodeMCU ESP8266 board, omitting the Content-Length header in the HTTP response leads to issues in web browsers like Chrome and Firefox, which fail to display the page. Chrome shows a blank page, while Firefox indicates "Connection was reset." The HTTP response received via Telnet confirms that the connection is closed after sending a simple HTML message. Despite the presence of the "Connection: close" header, the absence of Content-Length causes errors in tools like Curl and Wget as well. It is noted that the Content-Length header is essential for messages containing entity bodies unless chunked transfer encoding is utilized, which is not being applied in this case.
Swamp Thing
Insights Author
Messages
1,033
Reaction score
770
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
  • Like
Likes Swamp Thing
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top