Skip to content

Compilation Warning: Deprecated 'flush()' method used in WebServer.cpp #11976

@stef-ladefense

Description

@stef-ladefense

Board

Not hardware-specific. This is a framework library issue.

Device Description

N/A. The issue is in the core library, not related to a specific board.

Hardware Configuration

N/A

Version

v3.3.2

Type

Bug

IDE Name

VSCode with pioarduino

Operating System

win 11

Flash frequency

N/A

PSRAM enabled

yes

Upload speed

N/A

Description

A compilation warning (-Wdeprecated-declarations) is generated when compiling a project that uses the
WebServer library. The warning indicates that NetworkClient::flush() is deprecated and clear() should be
used instead. This happens in WebServer.cpp.
The project should compile cleanly without deprecation warnings from the core framework libraries.

Sketch

No specific sketch is required. Any basic sketch that includes and uses the WebServer library will trigger this warning during compilation.

The issue is located in WebServer.cpp at line 616.

  Problematic Code:
   1 // In function void WebServer::chunkResponseEnd()
   2 _chunkedClient.flush();

  Proposed Fix:
   1 // In function void WebServer::chunkResponseEnd()
   2 _chunkedClient.clear();

Debug Message

C:/Users/xxx/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.cpp: In member function 'void WebServer::chunkResponseEnd()':
 C:/Users/xxx/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.cpp:616:23 : warning: 'virtual void NetworkClient::flush()' is deprecated: Use clear() instead. [-Wdeprecated-declarations]
   616 |   _chunkedClient.flush();
       |   ~~~~~~~~~~~~~~~~~~~~^~
 In file included from C:/Users/xxx/.platformio/packages/framework-arduinoespressif32/libraries/Network/src/NetworkServer.h:23,
                  from C:/Users/xxx/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.cpp:28:
 C:/Users/xxx/.platformio/packages/framework-arduinoespressif32/libraries/Network/src/NetworkClient.h:61:8:note: declared here
    61 |   void flush();  // Print::flush tx

Other Steps to Reproduce

The issue is not dependent on specific hardware or sketch logic but is inherent to the library code within the
framework. It can be reproduced by simply compiling any project that has a dependency on the WebServer
library.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

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