-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Respect timeout with SSL #8899
base: master
Are you sure you want to change the base?
Respect timeout with SSL #8899
Conversation
d-a-v
commented
Mar 28, 2023
•
edited
Loading
edited
- Respect timeout with SSL, with HttpClient
- fixes Respect set timeout in WiFiClientSecureCtx #8889
- also needed for Core 3.1.1 - ESP8266HTTPClient.h getString() empty or truncated - read Timeout #8871
int connect(IPAddress ip, uint16_t port) override { uto(); return _ctx->connect(ip, port); } | ||
int connect(const String& host, uint16_t port) override { uto(); return _ctx->connect(host, port); } | ||
int connect(const char* name, uint16_t port) override { uto(); return _ctx->connect(name, port); } | ||
|
||
uint8_t connected() override { uto(); return _ctx->connected(); } | ||
size_t write(const uint8_t *buf, size_t size) override { uto(); return _ctx->write(buf, size); } | ||
size_t write_P(PGM_P buf, size_t size) override { uto(); return _ctx->write_P(buf, size); } | ||
size_t write(const char *buf) { uto(); return write((const uint8_t*)buf, strlen(buf)); } | ||
size_t write_P(const char *buf) { uto(); return write_P((PGM_P)buf, strlen_P(buf)); } | ||
size_t write(Stream& stream) /* Note this is not virtual */ { uto(); return _ctx->write(stream); } | ||
int read(uint8_t *buf, size_t size) override { uto(); return _ctx->read(buf, size); } | ||
int available() override { uto(); return _ctx->available(); } | ||
int availableForWrite() override { uto(); return _ctx->availableForWrite(); } | ||
int read() override { uto(); return _ctx->read(); } | ||
int peek() override { uto(); return _ctx->peek(); } | ||
size_t peekBytes(uint8_t *buffer, size_t length) override { uto(); return _ctx->peekBytes(buffer, length); } | ||
bool flush(unsigned int maxWaitMs) { uto(); return _ctx->flush(maxWaitMs); } | ||
bool stop(unsigned int maxWaitMs) { uto(); return _ctx->stop(maxWaitMs); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d-a-v/Arduino@ssltimeout...mcspr:esp8266-Arduino:ssltimeout ?
reiterating on the matrix discussion - no need to touch _timeout when not necessary, ctx class can have its own timeout state
implementing method override should fix the after-connect setting of timeout as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ctx
is not accessible from user side.
sslclient.setTimeout()
can be called from the Stream class (Stream& s = sslclient; s.setTimeout(1234);
)
Stream::setTimeout
is not virtual and I'm not sure that modifying Arduino API is not going to be a breaking change but you tell me.
Stream::_timeout
updates from client side are ignored until forwarded to the context _ctx
.
Considering that user can update this timeout anytime, I placed these many calls where _timeout
is used.
edit This commit reverts this one where there was an unwanted pointer of the client stream inside the context to help reaching user timeout.
edit2 now Stream::setTimeout()
is virtual