|
|
|
@ -10,12 +10,13 @@
|
|
|
|
|
namespace pEp {
|
|
|
|
|
namespace http = boost::beast::http;
|
|
|
|
|
|
|
|
|
|
url_split split_url(string url, string default_port)
|
|
|
|
|
url_split split_url(string url)
|
|
|
|
|
{
|
|
|
|
|
static auto url_pattern =
|
|
|
|
|
"^(?<protocol>\\w+)://"
|
|
|
|
|
"((?<login>\\S+)(:(?<password>\\S+))?@)?"
|
|
|
|
|
"(?<host>[\\w.-]+)"
|
|
|
|
|
"(:(?<port>\\d+))?"
|
|
|
|
|
"(?<path>[^#\\s]+)?"
|
|
|
|
|
"(?<hash>#\\w+)?$";
|
|
|
|
|
|
|
|
|
@ -31,8 +32,6 @@ namespace pEp {
|
|
|
|
|
result.host = what["host"];
|
|
|
|
|
if (what["port"].matched)
|
|
|
|
|
result.port = what["port"];
|
|
|
|
|
else
|
|
|
|
|
result.port = default_port;
|
|
|
|
|
result.path = what["path"];
|
|
|
|
|
if (result.path == "")
|
|
|
|
|
result.path = "/";
|
|
|
|
@ -54,6 +53,8 @@ namespace pEp {
|
|
|
|
|
throw runtime_error("login data unsupported");
|
|
|
|
|
if (u.hash != "")
|
|
|
|
|
throw runtime_error("hash unsupported");
|
|
|
|
|
if (u.port =="")
|
|
|
|
|
u.port = "443";
|
|
|
|
|
|
|
|
|
|
if (_stream)
|
|
|
|
|
throw runtime_error("stream already open");
|
|
|
|
@ -79,6 +80,7 @@ namespace pEp {
|
|
|
|
|
_stream->handshake(ssl::stream_base::client);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception&) {
|
|
|
|
|
_stream->next_layer().shutdown(tcp::socket::shutdown_both, ec);
|
|
|
|
|
delete _stream;
|
|
|
|
|
_stream = nullptr;
|
|
|
|
|
throw;
|
|
|
|
|