Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option "kCurlHttp_FollowLocation" #79

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW) # enable new "MSVC runtime library selection" (https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)

project(libCZI
VERSION 0.54.2
VERSION 0.54.3
ptahmose marked this conversation as resolved.
Show resolved Hide resolved
HOMEPAGE_URL "https://github.com/ZEISS/libczi"
DESCRIPTION "libCZI is an Open Source Cross-Platform C++ library to read and write CZI")

Expand Down
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
14 changes: 14 additions & 0 deletions Src/libCZI/StreamsLib/curlhttpinputstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@
ThrowIfCurlSetOptError(return_code, "CURLOPT_SSL_VERIFYHOST");
}

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

Check warning on line 173 in Src/libCZI/StreamsLib/curlhttpinputstream.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/StreamsLib/curlhttpinputstream.cpp#L172-L173

Added lines #L172 - L173 were not covered by tests
}

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");

Check warning on line 180 in Src/libCZI/StreamsLib/curlhttpinputstream.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/StreamsLib/curlhttpinputstream.cpp#L179-L180

Added lines #L179 - L180 were not covered by tests
}

this->curl_handle_ = up_curl_handle.release();
this->curl_url_handle_ = up_curl_url_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.
ptahmose marked this conversation as resolved.
Show resolved Hide resolved
};
};

Expand Down
Loading