-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ESP8266WebServer::client() should return a reference #7075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like this is a popular request. At first glance, though, it looks like a breaking API change. Would you like to do a PR with the change and see if it breaks any of the existing examples, @bblanchon ? Seems like it would be a simple tweak... If it does end up breaking things, then it probably need to be pushed to 3.0. If not, might make it into 2.7... |
@earlephilhower , I opened #7080 . |
@earlephilhower @d-a-v I seem to remember this was already tried, and it did break something. Or maybe it was with WiFiServer::available()? |
Hi,
Currently
ESP8266WebServer::client()
returns aWiFiClient
by value, which forbids passing the result directly to a function taking aClient&
.For example, it causes a compilation error with ArduinoJson:
serializeJson(doc, server.client());
Because
serializeJson()
takes aPrint&
, the line above produces the following error:To fix this problem,
ESP8266WebServer::client()
must return a reference (and not a copy), just asHTTPClient::getStream()
does.(see also this question on StackOverflow)
Best regards,
Benoit
The text was updated successfully, but these errors were encountered: