brainboxdotcc / DPP

C++ Discord API Bot Library - D++ is Lightweight and scalable for small and huge bots!
https://dpp.dev/
Apache License 2.0
1.01k stars 155 forks source link

feat: Add request_timeout, a parameter as optional to `cluster::request()` which allows user to set `http_client::timeout` and add error message for request timeouts #1186

Closed sony-string closed 1 week ago

sony-string commented 2 weeks ago

At now, cluster::request can't accept HTTP requests that require a long time to wait for response, especially which takes over 5 seconds. That's because there's no option to set http_client::timeout as user want. So, I added the optional parameter request_timeout to set it.

When an user calls cluster::request(), It would be passed through cluster::request() -> http_request::request_timeout (what I added in this commit) -> http_client::timeout

And also, http_request::run is printing Malformed HTTP response when request has timed out, so I fix it to print a log "Timed out while waiting for the response". For this, I needed to add a public member variable to http_client, timed_out which would be set by https_client::one_second_timer()

Code change checklist

CLAassistant commented 2 weeks ago

CLA assistant check
All committers have signed the CLA.

netlify[bot] commented 2 weeks ago

Deploy Preview for dpp-dev ready!

Name Link
Latest commit b61522d3eeae144a9d3539de2d0bdeff8e9ce9f3
Latest deploy log https://app.netlify.com/sites/dpp-dev/deploys/668541dcadc549000892f7ff
Deploy Preview https://deploy-preview-1186--dpp-dev.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.