{"action":"created","issue":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/1570","repository_url":"https://api.github.com/repos/esp8266/Arduino","labels_url":"https://api.github.com/repos/esp8266/Arduino/issues/1570/labels{/name}","comments_url":"https://api.github.com/repos/esp8266/Arduino/issues/1570/comments","events_url":"https://api.github.com/repos/esp8266/Arduino/issues/1570/events","html_url":"https://github.com/esp8266/Arduino/pull/1570","id":131319671,"number":1570,"title":"WiFiClient::write refactoring","user":{"login":"igrr","id":4349050,"avatar_url":"https://avatars.githubusercontent.com/u/4349050?v=3","gravatar_id":"","url":"https://api.github.com/users/igrr","html_url":"https://github.com/igrr","followers_url":"https://api.github.com/users/igrr/followers","following_url":"https://api.github.com/users/igrr/following{/other_user}","gists_url":"https://api.github.com/users/igrr/gists{/gist_id}","starred_url":"https://api.github.com/users/igrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igrr/subscriptions","organizations_url":"https://api.github.com/users/igrr/orgs","repos_url":"https://api.github.com/users/igrr/repos","events_url":"https://api.github.com/users/igrr/events{/privacy}","received_events_url":"https://api.github.com/users/igrr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-04T11:32:34Z","updated_at":"2016-02-06T20:04:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/esp8266/Arduino/pulls/1570","html_url":"https://github.com/esp8266/Arduino/pull/1570","diff_url":"https://github.com/esp8266/Arduino/pull/1570.diff","patch_url":"https://github.com/esp8266/Arduino/pull/1570.patch"},"body":"- Moved write behaviour (splitting payload into chunks, waiting for ACKs to arrive) from ClientContext into strategies.\r\n- Implemented `BufferStrategy` for payloads already present in RAM, and `ChunkedStrategy` for payloads which need to be copied to RAM on the fly.\r\n- WiFiClient::write(Stream&) will now send as much data as possible, as soon as possible. Previously it would send 1460 byte chunks, and would wait for each chunk to be ACKed before sending new one. Depending on network latency, this gives transfer speed increase within 25% — 100%.\r\n- WiFiClient will now get write timeout from `_timeout` member (1 second by default). Previously timeout was hard-coded to 5 seconds\r\n- ESP8266WebServer sets client timeout of 5 seconds before writing data. This is done to preserve old behaviour of WebServer.\r\n- `WiFiClientSecure` still has 5 seconds timeout hardcoded, some refactoring is necessary to expose `_timeout` member at the point when write function is called by axTLS.\r\n- ESP8266WebServer sendContent (_P) will now rely on WiFiClient::write (_P) to deliver the data"},"comment":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/comments/180848041","html_url":"https://github.com/esp8266/Arduino/pull/1570#issuecomment-180848041","issue_url":"https://api.github.com/repos/esp8266/Arduino/issues/1570","id":180848041,"user":{"login":"igrr","id":4349050,"avatar_url":"https://avatars.githubusercontent.com/u/4349050?v=3","gravatar_id":"","url":"https://api.github.com/users/igrr","html_url":"https://github.com/igrr","followers_url":"https://api.github.com/users/igrr/followers","following_url":"https://api.github.com/users/igrr/following{/other_user}","gists_url":"https://api.github.com/users/igrr/gists{/gist_id}","starred_url":"https://api.github.com/users/igrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igrr/subscriptions","organizations_url":"https://api.github.com/users/igrr/orgs","repos_url":"https://api.github.com/users/igrr/repos","events_url":"https://api.github.com/users/igrr/events{/privacy}","received_events_url":"https://api.github.com/users/igrr/received_events","type":"User","site_admin":false},"created_at":"2016-02-06T20:04:27Z","updated_at":"2016-02-06T20:04:27Z","body":"WiFiClient has the `write (const uint8_t*, size_t)` overloaded member function, both with and without these changes: https://github.com/esp8266/Arduino/blob/wificlient-strategies/libraries/ESP8266WiFi/src/WiFiClient.h#L50\r\n\r\nBefore these changes, we had an additional overloaded template member function `template <typename T> write(T& file, size_t unitSize)`. It was a bad design decision. When someone intended to call `write(const uint8_t*, size_t)` and passed a `const char*` for the first argument, compiler selected this template overload, which obviously failed due to lack of `.size()` member function for a POD type."}}