-
Notifications
You must be signed in to change notification settings - Fork 1
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
[OS-1068] Provide a timeout to the Http class #52
base: master
Are you sure you want to change the base?
Conversation
I've not looked at it yet, but please let's not merge until we fix the issue we are seeing in Dashboard with Python. Then we'll focus on adding this. |
absolutely agreed @radujipa - just wanted to get this code in a PR in the meantime. |
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.
Great idea, just a couple of suggestions.
namespace Mercury { | ||
namespace HTTP { | ||
|
||
#define DEFAULT_HTTP_CLIENT_TIMEOUT 15 // seconds |
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.
#define DEFAULT_HTTP_CLIENT_TIMEOUT 15 // seconds | |
const unsigned int DEFAULT_HTTP_CLIENT_TIMEOUT = 15; // seconds |
Also, is 15 seconds too long?
/** | ||
* \class HTTPClient | ||
* \brief Simple implementation of IHTTPClient | ||
*/ | ||
class HTTPClient : public IHTTPClient { | ||
public: | ||
HTTPClient(); | ||
HTTPClient(int timeout_secs); |
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.
Combine these two constructors into one?
HTTPClient(int timeout_secs); | |
HTTPClient(int timeout_secs = DEFAULT_HTTP_CLIENT_TIMEOUT); |
@@ -48,10 +48,13 @@ using Poco::Net::SSLManager; | |||
using Mercury::HTTP::HTTPClient; | |||
|
|||
|
|||
HTTPClient::HTTPClient() { | |||
HTTPClient::HTTPClient(int timeout_secs = DEFAULT_HTTP_CLIENT_TIMEOUT) { |
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.
Default arguments in header definition, not implementation.
@@ -62,6 +65,18 @@ HTTPClient::HTTPClient() { | |||
} | |||
|
|||
|
|||
void HTTPClient::set_http_client_timeout(int seconds) | |||
{ |
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.
{
on same line as definition.
} | ||
|
||
|
||
int HTTPClient::get_http_client_timeout() |
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.
Likewise here
Provide a means to set a timeout for the HTTP class.
It builds fine but haven't actually tested.
Also, needs a test to make sure the timeout is set and works correctly.