@@ -258,18 +258,22 @@ namespace nmos
258
258
259
259
namespace details
260
260
{
261
- // make a client for the specified base_uri and config, with Host header sneakily stashed in user info
261
+ // make a client for the specified base_uri and config, with host name for the Host header sneakily stashed in user info
262
262
std::unique_ptr<web::http::client::http_client> make_http_client (const web::uri& base_uri, const web::http::client::http_client_config& client_config)
263
263
{
264
- // unstash the Host header
264
+ // unstash the host name for the Host header
265
265
// cf. nmos::details::resolve_service
266
- const auto & host_name = base_uri.user_info ();
267
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));
268
- if (!host_name .empty ())
267
+ if (!base_uri. user_info () .empty ())
269
268
{
270
- client->add_handler ([host_name](web::http::http_request request, std::shared_ptr<web::http::http_pipeline_stage> next_stage) -> pplx::task<web::http::http_response>
269
+ auto host = base_uri.user_info ();
270
+ if (base_uri.port () > 0 )
271
271
{
272
- request.headers ().add (web::http::header_names::host, host_name);
272
+ host.append (U (" :" )).append (utility::conversions::details::to_string_t (base_uri.port ()));
273
+ }
274
+ 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>
275
+ {
276
+ request.headers ().add (web::http::header_names::host, host);
273
277
return next_stage->propagate (request);
274
278
});
275
279
}
0 commit comments