@@ -42,6 +42,7 @@ void UNIXSocketRequest::download(std::variant<TRequestParameters<std::string>,
4242 GetRequest::builder (FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))
4343 .url (arg.url .url (), arg.secureCommunication )
4444 .unixSocketPath (arg.url .unixSocketPath ())
45+ .appendHeaders (arg.httpHeaders )
4546 .timeout (timeout)
4647 .userAgent (userAgent)
4748 .outputFile (outputFile)
@@ -102,6 +103,7 @@ void UNIXSocketRequest::post(std::variant<TRequestParameters<std::string>,
102103 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
103104 req.url (arg.url .url (), arg.secureCommunication )
104105 .unixSocketPath (arg.url .unixSocketPath ())
106+ .appendHeaders (arg.httpHeaders )
105107 .timeout (timeout)
106108 .userAgent (userAgent)
107109 .template postData <const std::string&>(arg.data )
@@ -128,6 +130,7 @@ void UNIXSocketRequest::post(std::variant<TRequestParameters<std::string>,
128130 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
129131 req.url (arg.url .url (), arg.secureCommunication )
130132 .unixSocketPath (arg.url .unixSocketPath ())
133+ .appendHeaders (arg.httpHeaders )
131134 .timeout (timeout)
132135 .userAgent (userAgent)
133136 .template postData <std::string_view>(arg.data )
@@ -156,6 +159,7 @@ void UNIXSocketRequest::post(std::variant<TRequestParameters<std::string>,
156159 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
157160 req.url (arg.url .url (), arg.secureCommunication )
158161 .unixSocketPath (arg.url .unixSocketPath ())
162+ .appendHeaders (arg.httpHeaders )
159163 .timeout (timeout)
160164 .userAgent (userAgent)
161165 .template postData <const std::string&>(data)
@@ -234,6 +238,7 @@ void UNIXSocketRequest::get(std::variant<TRequestParameters<std::string>,
234238 GetRequest::builder (FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
235239 req.url (arg.url .url (), arg.secureCommunication )
236240 .unixSocketPath (arg.url .unixSocketPath ())
241+ .appendHeaders (arg.httpHeaders )
237242 .timeout (timeout)
238243 .userAgent (userAgent)
239244 .outputFile (outputFile)
@@ -309,6 +314,7 @@ void UNIXSocketRequest::put(std::variant<TRequestParameters<std::string>,
309314 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
310315 req.url (arg.url .url (), arg.secureCommunication )
311316 .unixSocketPath (arg.url .unixSocketPath ())
317+ .appendHeaders (arg.httpHeaders )
312318 .timeout (timeout)
313319 .userAgent (userAgent)
314320 .template postData <const std::string&>(arg.data )
@@ -336,6 +342,7 @@ void UNIXSocketRequest::put(std::variant<TRequestParameters<std::string>,
336342 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
337343 req.url (arg.url .url (), arg.secureCommunication )
338344 .unixSocketPath (arg.url .unixSocketPath ())
345+ .appendHeaders (arg.httpHeaders )
339346 .timeout (timeout)
340347 .userAgent (userAgent)
341348 .template postData <std::string_view>(arg.data )
@@ -364,6 +371,7 @@ void UNIXSocketRequest::put(std::variant<TRequestParameters<std::string>,
364371 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
365372 req.url (arg.url .url (), arg.secureCommunication )
366373 .template postData <const std::string&>(data)
374+ .unixSocketPath (arg.url .unixSocketPath ())
367375 .appendHeaders (arg.httpHeaders )
368376 .timeout (timeout)
369377 .userAgent (userAgent)
@@ -445,6 +453,7 @@ void UNIXSocketRequest::patch(std::variant<TRequestParameters<std::string>,
445453 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
446454 req.url (arg.url .url (), arg.secureCommunication )
447455 .unixSocketPath (arg.url .unixSocketPath ())
456+ .appendHeaders (arg.httpHeaders )
448457 .timeout (timeout)
449458 .userAgent (userAgent)
450459 .template postData <const std::string&>(arg.data )
@@ -472,6 +481,7 @@ void UNIXSocketRequest::patch(std::variant<TRequestParameters<std::string>,
472481 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
473482 req.url (arg.url .url (), arg.secureCommunication )
474483 .unixSocketPath (arg.url .unixSocketPath ())
484+ .appendHeaders (arg.httpHeaders )
475485 .timeout (timeout)
476486 .userAgent (userAgent)
477487 .template postData <std::string_view>(arg.data )
@@ -500,6 +510,7 @@ void UNIXSocketRequest::patch(std::variant<TRequestParameters<std::string>,
500510 FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
501511 req.url (arg.url .url (), arg.secureCommunication )
502512 .unixSocketPath (arg.url .unixSocketPath ())
513+ .appendHeaders (arg.httpHeaders )
503514 .timeout (timeout)
504515 .userAgent (userAgent)
505516 .template postData <const std::string&>(data)
@@ -574,29 +585,96 @@ void UNIXSocketRequest::delete_(std::variant<TRequestParameters<std::string>,
574585 std::visit (
575586 [&](auto && arg)
576587 {
577- auto req {DeleteRequest::builder (
578- FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
579- req.url (arg.url .url (), arg.secureCommunication )
580- .unixSocketPath (arg.url .unixSocketPath ())
581- .timeout (timeout)
582- .userAgent (userAgent)
583- .outputFile (outputFile)
584- .execute ();
588+ using T = std::decay_t <decltype (arg)>;
589+ if constexpr (std::is_same_v<T, TRequestParameters<std::string>>)
590+ {
591+ auto req {DeleteRequest::builder (
592+ FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
593+ req.url (arg.url .url (), arg.secureCommunication )
594+ .unixSocketPath (arg.url .unixSocketPath ())
595+ .appendHeaders (arg.httpHeaders )
596+ .timeout (timeout)
597+ .userAgent (userAgent)
598+ .template postData <const std::string&>(arg.data )
599+ .outputFile (outputFile)
600+ .execute ();
585601
586- std::visit (
587- [&](auto && arg)
588- {
589- using Tb = std::decay_t <decltype (arg)>;
590- if constexpr (std::is_same_v<Tb, TPostRequestParameters<const std::string&>>)
602+ std::visit (
603+ [&](auto && arg)
591604 {
592- arg.onSuccess (response);
593- }
594- else if constexpr (std::is_same_v<Tb, TPostRequestParameters<std::string&&>>)
605+ using Tb = std::decay_t <decltype (arg)>;
606+ if constexpr (std::is_same_v<Tb, TPostRequestParameters<const std::string&>>)
607+ {
608+ arg.onSuccess (response);
609+ }
610+ else if constexpr (std::is_same_v<Tb, TPostRequestParameters<std::string&&>>)
611+ {
612+ arg.onSuccess (std::move (response));
613+ }
614+ },
615+ postRequestParameters);
616+ }
617+ else if constexpr (std::is_same_v<T, TRequestParameters<std::string_view>>)
618+ {
619+ auto req {DeleteRequest::builder (
620+ FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
621+ req.url (arg.url .url (), arg.secureCommunication )
622+ .unixSocketPath (arg.url .unixSocketPath ())
623+ .appendHeaders (arg.httpHeaders )
624+ .timeout (timeout)
625+ .userAgent (userAgent)
626+ .template postData <std::string_view>(arg.data )
627+ .outputFile (outputFile)
628+ .execute ();
629+
630+ std::visit (
631+ [&](auto && arg)
595632 {
596- arg.onSuccess (std::move (response));
597- }
598- },
599- postRequestParameters);
633+ using Tb = std::decay_t <decltype (arg)>;
634+ if constexpr (std::is_same_v<Tb, TPostRequestParameters<const std::string&>>)
635+ {
636+ arg.onSuccess (response);
637+ }
638+ else if constexpr (std::is_same_v<Tb, TPostRequestParameters<std::string&&>>)
639+ {
640+ arg.onSuccess (std::move (response));
641+ }
642+ },
643+ postRequestParameters);
644+ }
645+ else if constexpr (std::is_same_v<T, TRequestParameters<nlohmann::json>>)
646+ {
647+ const auto data = arg.data .dump ();
648+ auto req {DeleteRequest::builder (
649+ FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
650+ req.url (arg.url .url (), arg.secureCommunication )
651+ .unixSocketPath (arg.url .unixSocketPath ())
652+ .template postData <const std::string&>(data)
653+ .appendHeaders (arg.httpHeaders )
654+ .timeout (timeout)
655+ .userAgent (userAgent)
656+ .outputFile (outputFile)
657+ .execute ();
658+
659+ std::visit (
660+ [&](auto && arg)
661+ {
662+ using Tb = std::decay_t <decltype (arg)>;
663+ if constexpr (std::is_same_v<Tb, TPostRequestParameters<const std::string&>>)
664+ {
665+ arg.onSuccess (response);
666+ }
667+ else if constexpr (std::is_same_v<Tb, TPostRequestParameters<std::string&&>>)
668+ {
669+ arg.onSuccess (std::move (response));
670+ }
671+ },
672+ postRequestParameters);
673+ }
674+ else
675+ {
676+ throw std::runtime_error (" Invalid type" );
677+ }
600678 },
601679 requestParameters);
602680 }
0 commit comments