@@ -282,10 +282,22 @@ create_request(
282
282
// Set user provided headers
283
283
if (vm.count (" header" ))
284
284
{
285
- for (auto & header : vm.at (" header" ).as <std::vector<std::string>>())
285
+ for (core::string_view header : vm.at (" header" ).as <std::vector<std::string>>())
286
286
{
287
287
if (auto pos = header.find (' :' ); pos != std::string::npos)
288
- request.set (header.substr (0 , pos), header.substr (pos + 1 ));
288
+ {
289
+ auto name = header.substr (0 , pos);
290
+ auto value = header.substr (pos + 1 );
291
+ if (!value.empty ())
292
+ request.set (name, value);
293
+ else
294
+ request.erase (name);
295
+ }
296
+ else if (auto pos = header.find (' ;' ); pos != std::string::npos)
297
+ {
298
+ auto name = header.substr (0 , pos);
299
+ request.set (name, " " );
300
+ }
289
301
}
290
302
}
291
303
@@ -757,12 +769,12 @@ main(int argc, char* argv[])
757
769
if (vm.count (" form" ))
758
770
{
759
771
auto form = multipart_form{};
760
- for (auto & data : vm.at (" form" ).as <std::vector<std::string>>())
772
+ for (core::string_view data : vm.at (" form" ).as <std::vector<std::string>>())
761
773
{
762
- if (auto pos = data.find (' =' ); pos != std::string ::npos)
774
+ if (auto pos = data.find (' =' ); pos != core::string_view ::npos)
763
775
{
764
- auto name = core::string_view{ data } .substr (0 , pos);
765
- auto value = core::string_view{ data } .substr (pos + 1 );
776
+ auto name = data.substr (0 , pos);
777
+ auto value = data.substr (pos + 1 );
766
778
if (!value.empty () && value[0 ] == ' @' )
767
779
{
768
780
form.append_file (
@@ -788,9 +800,9 @@ main(int argc, char* argv[])
788
800
{
789
801
if (vm.count (" get" ))
790
802
{
791
- for (auto data : vm.at (" data" ).as <std::vector<std::string>>())
803
+ for (core::string_view data : vm.at (" data" ).as <std::vector<std::string>>())
792
804
{
793
- if (auto pos = data.find (' =' ); pos != std::string ::npos)
805
+ if (auto pos = data.find (' =' ); pos != core::string_view ::npos)
794
806
{
795
807
url.params ().append (
796
808
{ data.substr (0 , pos), data.substr (pos + 1 ) });
@@ -804,15 +816,15 @@ main(int argc, char* argv[])
804
816
else
805
817
{
806
818
auto form = urlencoded_form{};
807
- for (auto & data : vm.at (" data" ).as <std::vector<std::string>>())
819
+ for (core::string_view data : vm.at (" data" ).as <std::vector<std::string>>())
808
820
{
809
821
if (!data.empty () && data[0 ] == ' @' )
810
822
{
811
823
form.append (any_istream{ data.substr (1 ) });
812
824
}
813
825
else
814
826
{
815
- if (auto pos = data.find (' =' ); pos != std::string ::npos)
827
+ if (auto pos = data.find (' =' ); pos != core::string_view ::npos)
816
828
{
817
829
form.append (
818
830
data.substr (0 , pos),
@@ -831,7 +843,7 @@ main(int argc, char* argv[])
831
843
if (vm.count (" json" ))
832
844
{
833
845
auto body = json_body{};
834
- for (auto & data : vm.at (" json" ).as <std::vector<std::string>>())
846
+ for (core::string_view data : vm.at (" json" ).as <std::vector<std::string>>())
835
847
{
836
848
if (data.empty ())
837
849
continue ;
@@ -856,10 +868,10 @@ main(int argc, char* argv[])
856
868
857
869
if (vm.count (" cookie" ))
858
870
{
859
- for (auto & option : vm.at (" cookie" ).as <std::vector<std::string>>())
871
+ for (core::string_view option : vm.at (" cookie" ).as <std::vector<std::string>>())
860
872
{
861
873
// empty options are allowerd and just activates cookie engine
862
- if (option.find (' =' ) != std::string ::npos)
874
+ if (option.find (' =' ) != core::string_view ::npos)
863
875
{
864
876
if (!explicit_cookies.ends_with (' ;' ))
865
877
explicit_cookies.push_back (' ;' );
0 commit comments