Move set_proxy() to Instance.
This commit is contained in:
parent
8482f51aff
commit
e4a5b8e9ce
|
@ -99,13 +99,6 @@ public:
|
||||||
return get(endpoint, {});
|
return get(endpoint, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @copydoc CURLWrapper::set_proxy(string_view)
|
|
||||||
*
|
|
||||||
* Sets also the proxy for the Instance you used to initialize this
|
|
||||||
* Connection.
|
|
||||||
*/
|
|
||||||
void set_proxy(string_view proxy);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Copy new stream contents and delete the “original”.
|
* @brief Copy new stream contents and delete the “original”.
|
||||||
*
|
*
|
||||||
|
|
|
@ -95,11 +95,35 @@ public:
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
uint64_t get_max_chars();
|
uint64_t get_max_chars();
|
||||||
|
|
||||||
|
/*! @copydoc CURLWrapper::set_proxy(string_view)
|
||||||
|
*
|
||||||
|
* Sets also the proxy for all Connection%s that are initialized with this
|
||||||
|
* Instance afterwards.
|
||||||
|
*/
|
||||||
|
void set_proxy(const string_view proxy)
|
||||||
|
{
|
||||||
|
_proxy = proxy;
|
||||||
|
CURLWrapper::set_proxy(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the proxy string that was previously set.
|
||||||
|
*
|
||||||
|
* Does not return the proxy if it was set from an environment variable.
|
||||||
|
*
|
||||||
|
* @since 0.1.0
|
||||||
|
*/
|
||||||
|
string_view get_proxy() const
|
||||||
|
{
|
||||||
|
return _proxy;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const string _hostname;
|
const string _hostname;
|
||||||
const string _baseuri;
|
const string _baseuri;
|
||||||
string _access_token;
|
string _access_token;
|
||||||
uint64_t _max_chars;
|
uint64_t _max_chars;
|
||||||
|
string _proxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mastodonpp
|
} // namespace mastodonpp
|
||||||
|
|
|
@ -24,7 +24,13 @@ using std::holds_alternative;
|
||||||
Connection::Connection(Instance &instance)
|
Connection::Connection(Instance &instance)
|
||||||
: _instance{instance}
|
: _instance{instance}
|
||||||
, _baseuri{instance.get_baseuri()}
|
, _baseuri{instance.get_baseuri()}
|
||||||
{}
|
{
|
||||||
|
auto proxy{_instance.get_proxy()};
|
||||||
|
if (!proxy.empty())
|
||||||
|
{
|
||||||
|
CURLWrapper::set_proxy(proxy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
answer_type Connection::get(const endpoint_variant &endpoint,
|
answer_type Connection::get(const endpoint_variant &endpoint,
|
||||||
const parametermap ¶meters)
|
const parametermap ¶meters)
|
||||||
|
@ -42,12 +48,6 @@ answer_type Connection::get(const endpoint_variant &endpoint,
|
||||||
return make_request(http_method::GET, uri, parameters);
|
return make_request(http_method::GET, uri, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::set_proxy(const string_view proxy)
|
|
||||||
{
|
|
||||||
CURLWrapper::set_proxy(proxy);
|
|
||||||
_instance.set_proxy(proxy);
|
|
||||||
}
|
|
||||||
|
|
||||||
string Connection::get_new_stream_contents()
|
string Connection::get_new_stream_contents()
|
||||||
{
|
{
|
||||||
buffer_mutex.lock();
|
buffer_mutex.lock();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user