Skip to content

Commit 9ca07aa

Browse files
committed
Merge branch 'master' into update-doc
2 parents df537e4 + 49649f8 commit 9ca07aa

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

Development/nmos/client_utils.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,24 @@ namespace nmos
263263
{
264264
// unstash the host name for the Host header
265265
// cf. nmos::details::resolve_service
266-
std::unique_ptr<web::http::client::http_client> client(new web::http::client::http_client(web::uri_builder(base_uri).set_user_info({}).to_uri(), client_config));
266+
// don't bother clearing user_info since http_client makes no use of it
267+
// see https://github.com/microsoft/cpprestsdk/issues/3
268+
std::unique_ptr<web::http::client::http_client> client(new web::http::client::http_client(base_uri, client_config));
267269
if (!base_uri.user_info().empty())
268270
{
269271
auto host = base_uri.user_info();
270-
if (base_uri.port() > 0)
272+
273+
// hmm, in secure mode, don't append the port to the Host header
274+
// because both calc_cn_host in cpprestsdk/Release/src/http/client/http_client_asio.cpp
275+
// and winhttp_client::send_request in cpprestsdk/Release/src/http/client/http_client_winhttp.cpp
276+
// compare the entire Host header value with the certificate Common Name
277+
// which causes an SSL handshake error
278+
// see https://github.com/microsoft/cpprestsdk/issues/1790
279+
if (base_uri.port() > 0 && !web::is_secure_uri_scheme(base_uri.scheme()))
271280
{
272281
host.append(U(":")).append(utility::conversions::details::to_string_t(base_uri.port()));
273282
}
283+
274284
client->add_handler([host](web::http::http_request request, std::shared_ptr<web::http::http_pipeline_stage> next_stage) -> pplx::task<web::http::http_response>
275285
{
276286
request.headers().add(web::http::header_names::host, host);

Development/nmos/node_behaviour.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ namespace nmos
554554
// Location may be a relative (to the request URL) or absolute URL
555555
auto request_uri = web::uri_builder(client.base_uri()).append_path(U("/resource")).to_uri();
556556
auto location_uri = request_uri.resolve_uri(response.headers()[web::http::header_names::location]);
557-
deletion = api_request(web::http::client::http_client(location_uri, client.client_config()), web::http::methods::DEL, gate, token);
557+
auto deletion_client = nmos::details::make_http_client(location_uri, client.client_config());
558+
deletion = api_request(*deletion_client, web::http::methods::DEL, gate, token);
558559
}
559560
else
560561
{
@@ -784,7 +785,7 @@ namespace nmos
784785

785786
self_id = id_type.first;
786787

787-
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Registering nmos-cpp node with the Registration API at: " << registration_client->base_uri().host() << ":" << registration_client->base_uri().port();
788+
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Registering nmos-cpp node with the Registration API at: " << registration_client->base_uri().to_string();
788789

789790
auto token = cancellation_source.get_token();
790791
request = details::request_registration(*registration_client, events.at(0), gate, token).then([&](pplx::task<void> finally)
@@ -908,7 +909,7 @@ namespace nmos
908909
// "The first interaction with a new Registration API [after a server side or connectivity issue]
909910
// should be a heartbeat to confirm whether whether the Node is still present in the registry"
910911

911-
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Attempting registration heartbeats with the Registration API at: " << registration_client->base_uri().host() << ":" << registration_client->base_uri().port();
912+
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Attempting registration heartbeats with the Registration API at: " << registration_client->base_uri().to_string();
912913

913914
node_registered = false;
914915

Development/nmos/node_server.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "nmos/channelmapping_activation.h"
66
#include "nmos/events_api.h"
77
#include "nmos/events_ws_api.h"
8+
#include "nmos/is04_versions.h"
89
#include "nmos/logging_api.h"
910
#include "nmos/manifest_api.h"
1011
#include "nmos/model.h"
@@ -25,7 +26,13 @@ namespace nmos
2526
{
2627
// Log the API addresses we'll be using
2728

28-
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Configuring nmos-cpp node with its primary Node API at: " << nmos::get_host(node_model.settings) << ":" << nmos::fields::node_port(node_model.settings);
29+
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Configuring nmos-cpp node with its primary Node API at: "
30+
<< web::uri_builder()
31+
.set_scheme(nmos::http_scheme(node_model.settings))
32+
.set_host(nmos::get_host(node_model.settings))
33+
.set_port(nmos::fields::node_port(node_model.settings))
34+
.set_path(U("/x-nmos/node/") + nmos::make_api_version(*nmos::is04_versions::from_settings(node_model.settings).rbegin()))
35+
.to_string();
2936

3037
nmos::server node_server{ node_model };
3138

Development/nmos/registry_server.cpp

+21-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,27 @@ namespace nmos
3333
{
3434
// Log the API addresses we'll be using
3535

36-
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Configuring nmos-cpp registry with its primary Node API at: " << nmos::get_host(registry_model.settings) << ":" << nmos::fields::node_port(registry_model.settings);
37-
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Configuring nmos-cpp registry with its primary Registration API at: " << nmos::get_host(registry_model.settings) << ":" << nmos::fields::registration_port(registry_model.settings);
38-
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Configuring nmos-cpp registry with its primary Query API at: " << nmos::get_host(registry_model.settings) << ":" << nmos::fields::query_port(registry_model.settings);
36+
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Configuring nmos-cpp registry with its primary Node API at: "
37+
<< web::uri_builder()
38+
.set_scheme(nmos::http_scheme(registry_model.settings))
39+
.set_host(nmos::get_host(registry_model.settings))
40+
.set_port(nmos::fields::node_port(registry_model.settings))
41+
.set_path(U("/x-nmos/node/") + nmos::make_api_version(*nmos::is04_versions::from_settings(registry_model.settings).rbegin()))
42+
.to_string();
43+
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Configuring nmos-cpp registry with its primary Registration API at: "
44+
<< web::uri_builder()
45+
.set_scheme(nmos::http_scheme(registry_model.settings))
46+
.set_host(nmos::get_host(registry_model.settings))
47+
.set_port(nmos::fields::registration_port(registry_model.settings))
48+
.set_path(U("/x-nmos/registration/") + nmos::make_api_version(*nmos::is04_versions::from_settings(registry_model.settings).rbegin()))
49+
.to_string();
50+
slog::log<slog::severities::info>(gate, SLOG_FLF) << "Configuring nmos-cpp registry with its primary Query API at: "
51+
<< web::uri_builder()
52+
.set_scheme(nmos::http_scheme(registry_model.settings))
53+
.set_host(nmos::get_host(registry_model.settings))
54+
.set_port(nmos::fields::query_port(registry_model.settings))
55+
.set_path(U("/x-nmos/query/") + nmos::make_api_version(*nmos::is04_versions::from_settings(registry_model.settings).rbegin()))
56+
.to_string();
3957

4058
nmos::server registry_server{ registry_model };
4159

0 commit comments

Comments
 (0)