Skip to content

Commit

Permalink
add option "kCurlHttp_FollowLocation"
Browse files Browse the repository at this point in the history
  • Loading branch information
ptahmose committed Nov 15, 2023
1 parent fac8eff commit 31026ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Src/CZICmd/cmdlineoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2194,6 +2194,8 @@ void CCmdLineOptions::PrintHelpStreamsObjects()
{"CurlHttp_Cookie", libCZI::StreamsFactory::StreamProperties::kCurlHttp_Cookie, libCZI::StreamsFactory::Property::Type::String},
{"CurlHttp_SslVerifyPeer", libCZI::StreamsFactory::StreamProperties::kCurlHttp_SslVerifyPeer, libCZI::StreamsFactory::Property::Type::Boolean},
{"CurlHttp_SslVerifyHost", libCZI::StreamsFactory::StreamProperties::kCurlHttp_SslVerifyHost, libCZI::StreamsFactory::Property::Type::Boolean},
{"CurlHttp_FollowLocation", libCZI::StreamsFactory::StreamProperties::kCurlHttp_FollowLocation, libCZI::StreamsFactory::Property::Type::Boolean},
{"CurlHttp_MaxRedirs", libCZI::StreamsFactory::StreamProperties::kCurlHttp_MaxRedirs, libCZI::StreamsFactory::Property::Type::Int32},
};

rapidjson::Document document;
Expand Down
13 changes: 10 additions & 3 deletions Src/libCZI/StreamsLib/curlhttpinputstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,18 @@ CurlHttpInputStream::CurlHttpInputStream(const std::string& url, const std::map<
ThrowIfCurlSetOptError(return_code, "CURLOPT_SSL_VERIFYPEER");
}

property = property_bag.find(StreamsFactory::StreamProperties::kCurlHttp_SslVerifyHost);
property = property_bag.find(StreamsFactory::StreamProperties::kCurlHttp_FollowLocation);
if (property != property_bag.end())
{
return_code = curl_easy_setopt(up_curl_handle.get(), CURLOPT_SSL_VERIFYHOST, property->second.GetAsBoolOrThrow() ? 1L : 0L);
ThrowIfCurlSetOptError(return_code, "CURLOPT_SSL_VERIFYHOST");
return_code = curl_easy_setopt(up_curl_handle.get(), CURLOPT_FOLLOWLOCATION, property->second.GetAsBoolOrThrow() ? 1L : 0L);
ThrowIfCurlSetOptError(return_code, "CURLOPT_FOLLOWLOCATION");
}

property = property_bag.find(StreamsFactory::StreamProperties::kCurlHttp_MaxRedirs);
if (property != property_bag.end())
{
return_code = curl_easy_setopt(up_curl_handle.get(), CURLOPT_MAXREDIRS, property->second.GetAsInt32OrThrow());
ThrowIfCurlSetOptError(return_code, "CURLOPT_MAXREDIRS");
}

this->curl_handle_ = up_curl_handle.release();
Expand Down
4 changes: 4 additions & 0 deletions Src/libCZI/libCZI_StreamsLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ namespace libCZI
kCurlHttp_SslVerifyPeer = 106, ///< For CurlHttpInputStream, type bool: a boolean indicating whether the SSL-certificate of the remote host is to be verified, c.f. https://curl.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html for more information.

kCurlHttp_SslVerifyHost = 107, ///< For CurlHttpInputStream, type bool: a boolean indicating whether the SSL-certificate's name is to be verified against host, c.f. https://curl.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html for more information.

kCurlHttp_FollowLocation = 108, ///< For CurlHttpInputStream, type bool: a boolean indicating whether redirects are to be followed, c.f. https://curl.se/libcurl/c/CURLOPT_FOLLOWLOCATION.html for more information.

kCurlHttp_MaxRedirs = 109, ///< For CurlHttpInputStream, type int32: gives the maximum number of redirects to follow, c.f. https://curl.se/libcurl/c/CURLOPT_MAXREDIRS.html for more information.
};
};

Expand Down

0 comments on commit 31026ee

Please sign in to comment.