Skip to content

net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK) while trying to send huge data/image.  #8906

@kayakaantuna

Description

@kayakaantuna

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-WROOM-02
  • Core Version: 3.0.2
  • Development Env: Arduino IDE
  • Operating System: Windows

Settings in IDE

  • Module: Generic ESP8266 Module
  • Flash Mode: DOUT
  • Flash Size: 2MB
  • lwip Variant: v2 Lower Memory
  • Reset Method: nodemcu
  • Flash Frequency: 40Mhz
  • CPU Frequency: 160MHz
  • Upload Using: OTA&SERIAL
  • Upload Speed: 115200

Problem Description

I'm using this library to upload about 500kb jpg image to the "http://ESPIPaddress:80/" address, however I get "net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)" from the chrome browser. I only can see %10 of the image before I get the error.

Since its a huge data for ESP8266, I'm getting the image from another microchip using SPI communication. So I'm using server.sendContent(); function. When I setup an PHP server I can see the image perfectly but I want this to be standalone and not dependent to the PHP server I open from OS.

Here is the related code:

MCVE Sketch

if(POSTcheck){
    server.setContentLength(u_image_size);
    String header = String(F("HTTP/1.1 200 OK\r\n"));
    header += String(F("Content-Type: image/jpg\r\n"));
    header += String(F("Content-Length: "));
    header += String(u_image_size);
    header += String(F("\r\n"));
    header += String(F("Connection: Close\r\n\r\n"));
    uint32_t total_length = head.length() + tail.length() + u_image_size;
    server.sendContent(header.c_str(), header.length());
    POSTcheck = false;
    }

    if(uart_rx_idx_ctr % UART_RX_PACKET_SIZE == 0)
      { 
        esp_counter++;
        server.sendContent_P((char *)&buf, UART_RX_PACKET_SIZE);
        is_buf_full = 0;
        conti = false;
        interrupts();
        Serial.write(ready_to_receive);
      }
      else
      {
        esp_counter++;
        uint16_t remain = uart_rx_idx_ctr % UART_RX_PACKET_SIZE;
        uint8_t packet_num = remain / SERVER_SEND_PACKET_SIZE;
        uint8_t remain_mod = remain % SERVER_SEND_PACKET_SIZE;
        uint8_t i = 0;
        server.sendContent_P((char *)&buf, remain);
        delay(500);
        is_buf_full = 0;

        finit = true;
        PHPupload = true;
        
      }  

Basically, when SPI data length reaches to max RAM size it enters this function and send it to the server.

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