I am not sure that i use right patter, so please correct me. I am writing a library that communicates with server. In constructor i receive url and immediately create uniq_ptr<http_client> with specified URL as constructor parameter. I reuse this client
for different requests by using uri_builder (is this Ok pattern?).
Later I can receive user/name and password and will want to update client_config with credentials. but _mainClient->client_config() returns const object that does not allow change.
Why? What is right way to handle this?
Oct 31, 2014 at 4:42 PM
Reusing http_client for different requests to different URIs - yes this is ok as long as they all share the same host name. For example you could construct the http_client with
and then make requests to different paths, hitting
The http_client configuration isn't mutable because the setting specified are used when connecting the client, they can't be updated after the connection is established. You have two options. One is don't create the http_client instance until you actually have
the credentials. Another is use a second different http_client with your credentials.