Skip to content

ESP8266WebServer chunked transfer is broken #6877

Closed
@hvxl

Description

@hvxl

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: [ESP-12]
  • Core Version: [074a801]
  • Development Env: [Arduino IDE]
  • Operating System: [openSUSE]

Settings in IDE

  • Module: [NodeMCU 1.0 (ESP-12E Module)]
  • Flash Mode: [qio]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [921600] (serial upload only)

Problem Description

Since 2.6.2 chunked HTTP is broken because the web server sends chunk lengths in the wrong location. For one thing, it's sending a chunk length before the headers. For example, the sketch below results in the following data being transmitted (as reported by wireshark):

71
HTTP/1.1 200 OK
Content-Type: text/plain
Accept-Ranges: none
Transfer-Encoding: chunked
Connection: close


0

Webserver bug!

Git bisect indicates that 36f9034 is the first bad commit.

MCVE Sketch

#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

void handleRoot() {
  server.setContentLength(CONTENT_LENGTH_UNKNOWN);
  server.send(200, "text/plain", "");
  server.sendContent("Webserver bug!");
}

void setup() {
  Serial.begin(115200);
  WiFi.begin();
  while (WiFi.status() != WL_CONNECTED) delay(500);
  Serial.println(WiFi.localIP());
  server.on("/", HTTP_GET, handleRoot);
  server.begin();
}

void loop() {
  server.handleClient();
}

Debug Messages

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions