URL Parse fix
This commit is contained in:
parent
f26225946c
commit
5aecba03ef
@ -124,6 +124,16 @@ namespace fr
|
||||
*/
|
||||
static const std::string &scheme_to_string(Scheme scheme);
|
||||
|
||||
/*!
|
||||
* Comparison operator
|
||||
*
|
||||
* @param o Object to compare against
|
||||
* @return True if equal, false otherwise
|
||||
*/
|
||||
inline bool operator==(const URL &o) const
|
||||
{
|
||||
return scheme == o.scheme && host == o.host && port == o.port && path == o.path && query == o.query && fragment == o.fragment;
|
||||
}
|
||||
private:
|
||||
/*!
|
||||
* Converts a string to lower case
|
||||
|
||||
@ -30,14 +30,14 @@ namespace fr
|
||||
error = mbedtls_x509_crt_parse_file(&srvcert, pem_path.c_str());
|
||||
if(error != 0)
|
||||
{
|
||||
throw std::runtime_error("mbedtls_x509_crt_parse_file() returned: " + std::to_string(error));
|
||||
throw std::runtime_error("Error parsing '" + pem_path + "': mbedtls_x509_crt_parse_file() returned " + std::to_string(error));
|
||||
}
|
||||
|
||||
//Load private key
|
||||
error = mbedtls_pk_parse_keyfile(&pkey, private_key_path.c_str(), 0);
|
||||
if(error != 0)
|
||||
{
|
||||
throw std::runtime_error("mbedtls_pk_parse_keyfile() returned: " + std::to_string(error));
|
||||
throw std::runtime_error("Error parsing '" + private_key_path + "': mbedtls_pk_parse_keyfile() returned " + std::to_string(error));
|
||||
}
|
||||
|
||||
//Setup data structures and apply settings
|
||||
|
||||
@ -21,7 +21,6 @@ namespace fr
|
||||
};
|
||||
|
||||
URL::URL(const std::string &url)
|
||||
: scheme(Scheme::Unknown)
|
||||
{
|
||||
parse(url);
|
||||
}
|
||||
@ -29,6 +28,7 @@ namespace fr
|
||||
|
||||
void URL::parse(std::string url)
|
||||
{
|
||||
scheme = Scheme::Unknown;
|
||||
size_t parse_offset = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
|
||||
@ -65,3 +65,11 @@ TEST(URLTest, uri_test4)
|
||||
fr::URL url("http://example.com:80/?bob=10#frag");
|
||||
ASSERT_EQ(url.get_uri(), "/?bob=10#frag");
|
||||
}
|
||||
|
||||
TEST(URLTest, schema_parse_test)
|
||||
{
|
||||
fr::URL url("127.0.0.1:2020");
|
||||
fr::URL url2;
|
||||
url2.parse("127.0.0.1:2020");
|
||||
ASSERT_EQ(url, url2);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user