Skip to content

ESP8266WebServer::client() should return a reference #7075

Closed
@bblanchon

Description

@bblanchon

Hi,

Currently ESP8266WebServer::client() returns a WiFiClient by value, which forbids passing the result directly to a function taking a Client&.

For example, it causes a compilation error with ArduinoJson:

serializeJson(doc, server.client());

Because serializeJson() takes a Print&, the line above produces the following error:

no instance of overloaded function "serializeJson" matches the argument list -- argument types are: (ArduinoJson6141_0000010::StaticJsonDocument<768U>, WiFiServer::ClientType)

To fix this problem, ESP8266WebServer::client() must return a reference (and not a copy), just as HTTPClient::getStream() does.

(see also this question on StackOverflow)

Best regards,
Benoit

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