Merge branch 'develop' into main
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
commit
28f194c910
|
@ -27,7 +27,7 @@ namespace Export
|
|||
using std::string;
|
||||
|
||||
/*!
|
||||
* @brief Export as JSON array.
|
||||
* @brief Export as %JSON array.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Export
|
|||
using std::string;
|
||||
|
||||
/*!
|
||||
* @brief Export as RSS feed.
|
||||
* @brief Export as %RSS feed.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
:doctype: manpage
|
||||
:Author: tastytea
|
||||
:Email: tastytea@tastytea.de
|
||||
:Date: 2019-09-06
|
||||
:Date: 2019-09-20
|
||||
:Revision: 0.0.0
|
||||
:man source: remwharead
|
||||
:man manual: General Commands Manual
|
||||
|
@ -160,8 +160,10 @@ Currently only HTTP and HTTPS are supported.
|
|||
== PROXY SUPPORT
|
||||
|
||||
*remwharead* supports HTTP proxies set via the environment variable
|
||||
_http_proxy_. Accepted formats are _http://host:port/_ or _host:port_. No SOCKS
|
||||
proxy support yet, sorry.
|
||||
_http_proxy_. Accepted formats are: _\http://[user[:password]@]host[:port]/_ or
|
||||
_[user[:password]@]host[:port]_. No SOCKS proxy support yet, sorry.
|
||||
|
||||
Example: http_proxy="http://localhost:3128/"
|
||||
|
||||
== FILES
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace remwharead
|
|||
using std::unique_ptr;
|
||||
using std::make_unique;
|
||||
using std::vector;
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
using Poco::Net::HTTPClientSession;
|
||||
using Poco::Net::HTTPSClientSession;
|
||||
using Poco::Net::HTTPRequest;
|
||||
|
@ -67,31 +69,37 @@ namespace remwharead
|
|||
try
|
||||
{
|
||||
HTTPClientSession::ProxyConfig proxy;
|
||||
string proxy_env = Environment::get("http_proxy");
|
||||
size_t pos;
|
||||
const string env_proxy = Environment::get("http_proxy");
|
||||
const RegEx re_proxy("^(?:https?://)?(?:([^:]+):?([^@]*)@)?"
|
||||
"([^:/]+)(?::([\\d]{1,5}))?/?$");
|
||||
vector<string> matches;
|
||||
|
||||
// Only keep text between // and /.
|
||||
if ((pos = proxy_env.find("//")) != string::npos)
|
||||
if (re_proxy.split(env_proxy, matches) >= 4)
|
||||
{
|
||||
proxy_env = proxy_env.substr(pos + 2);
|
||||
}
|
||||
if ((pos = proxy_env.find('/')) != string::npos)
|
||||
proxy.username = matches[1];
|
||||
proxy.password = matches[2];
|
||||
proxy.host = matches[3];
|
||||
if (!matches[4].empty())
|
||||
{
|
||||
proxy_env = proxy_env.substr(0, pos);
|
||||
}
|
||||
|
||||
if ((pos = proxy_env.find(':')) != string::npos)
|
||||
const std::uint32_t &port = std::stoul(matches[4]);
|
||||
if (port > 65535)
|
||||
{
|
||||
proxy.host = proxy_env.substr(0, pos);
|
||||
proxy.port = std::stoi(proxy_env.substr(pos + 1));
|
||||
throw std::invalid_argument("Port number out of range");
|
||||
}
|
||||
proxy.port = port;
|
||||
}
|
||||
else
|
||||
{
|
||||
proxy.host = proxy_env;
|
||||
}
|
||||
|
||||
HTTPClientSession::setGlobalProxyConfig(proxy);
|
||||
}
|
||||
catch (const Poco::RegularExpressionException &e)
|
||||
{
|
||||
cerr << "Error: Proxy could not be set ("
|
||||
<< e.displayText() << ")\n";
|
||||
}
|
||||
catch (const std::invalid_argument &e)
|
||||
{
|
||||
cerr << "Error: " << e.what() << endl;
|
||||
}
|
||||
catch (const std::exception &)
|
||||
{
|
||||
// No proxy found, no problem.
|
||||
|
|
Loading…
Reference in New Issue