Skip to content

SDWebServer printDirectory CONTENT_LENGTH_UNKNOWN doesn't send last-chunk #2481

Closed
@JamesNewton

Description

@JamesNewton

Description

In the sample code, in the printDirectory routine, which is one of the only examples I can find where anyone uses
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
what closes the connection after the listing is returned?

Shouldn't there be a server.sendContent(""") at the end of the procedure?

When chunking is used, and no Content-Length is supplied in the Header of an HTTP 1.1 response, the last chunk is supposed to have zero length...
http://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.3.6.1
http://greenbytes.de/tech/webdav/rfc2616.html#introduction.of.transfer-encoding

Hardware

Hardware: ESP-12

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: DIO
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: nodemcu... actually manual.

Sketch

/libraries/ESP8266WebServer/examples/SDWebServer/SDWebServer.ino

Debug Messages

None... dang it... I don't know how to spy on the HTTP data.

What bothers me most is that the code appears to work... and I can't figure out why... Are modern browsers just closing the connection after a while? Nothing in the spec about that which I can find...

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions