You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Movable HTTPClient and fixing WiFiClient copy (esp8266#8237)
- =default for default ctor, destructor, move ctor and the assignment move
- use `std::unique_ptr<WiFiClient>` instead of raw pointer to the client
- implement `virtual std::unique_ptr<WiFiClient> WiFiClient::clone()` to safely copy the WiFiClientSecure instance, without accidentally slicing it (i.e. using the pointer with incorrect type, calling base WiFiClient virtual methods)
- replace headers pointer array with `std::unique_ptr<T[]>` to simplify the move operations
- substitute userAgent with the default one when it is empty
(may be a subject to change though, b/c now there is a global static `String`)
Allow HTTPClient to be placed inside of movable classes (e.g. std::optional, requested in the linked issue) or to be returned from functions. Class logic stays as-is, only the underlying member types are changed.
Notice that WiFiClient connection object is now copied, and the internal ClientContext will be preserved even after the original WiFiClient object was destroyed.
replaces esp8266#8236resolvesesp8266#8231
and, possibly esp8266#5734
@@ -231,13 +238,23 @@ class WiFiClientSecure : public WiFiClient {
231
238
// Instead, all virtual functions call their counterpart in "WiFiClientecureCtx* _ctx"
232
239
// which also derives from WiFiClient (this parent is the one which is eventually used)
233
240
241
+
// TODO: notice that this complicates the implementation by having two distinct ways the client connection is managed, consider:
242
+
// - implementing the secure connection details in the ClientContext
243
+
// (i.e. delegate the write & read functions there)
244
+
// - simplify the inheritance chain by implementing base wificlient class and inherit the original wificlient and wificlientsecure from it
245
+
// - abstract internals so it's possible to seamlessly =default copy and move with the instance *without* resorting to manual copy and initialization of each member
246
+
247
+
// TODO: prefer implementing virtual overrides in the .cpp (or, at least one of them)
0 commit comments