Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions cpp/src/arrow/flight/cookie_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ size_t CaseInsensitiveHash::operator()(const std::string& key) const {
return std::hash<std::string>{}(upper_string);
}

bool CaseInsensitiveEqual::operator()(std::string_view lhs,
std::string_view rhs) const {
if (lhs.size() != rhs.size()) return false;
return strcasecmp(std::string(lhs).c_str(), std::string(rhs).c_str()) == 0;
}

Cookie Cookie::Parse(std::string_view cookie_header_value) {
// Parse the cookie string. If the cookie has an expiration, record it.
// If the cookie has a max-age, calculate the current time + max_age and set that as
Expand Down
8 changes: 7 additions & 1 deletion cpp/src/arrow/flight/cookie_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class ARROW_FLIGHT_EXPORT CaseInsensitiveComparator {
bool operator()(const std::string& t1, const std::string& t2) const;
};

/// \brief Case insensitive equality comparator for use by unordered cookie map.
class ARROW_FLIGHT_EXPORT CaseInsensitiveEqual {
public:
bool operator()(const std::string& lhs, const std::string& rhs) const;
};

/// \brief Case insensitive hasher for use by cookie caching map. Cookies are not
/// case-sensitive.
class ARROW_FLIGHT_EXPORT CaseInsensitiveHash {
Expand Down Expand Up @@ -117,7 +123,7 @@ class ARROW_FLIGHT_EXPORT CookieCache {

// Mutex must be used to protect cookie cache.
std::mutex mutex_;
std::unordered_map<std::string, Cookie, CaseInsensitiveHash, CaseInsensitiveComparator>
std::unordered_map<std::string, Cookie, CaseInsensitiveHash, CaseInsensitiveEqual>
cookies;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ void FlightSqlConnection::Connect(const ConnPropertyMap& properties,
client_options_ =
BuildFlightClientOptions(properties, missing_attr, flight_ssl_configs);

const std::shared_ptr<ClientMiddlewareFactory>& cookie_factory = GetCookieFactory();
client_options_.middleware.push_back(cookie_factory);

std::unique_ptr<FlightClient> flight_client;
ThrowIfNotOK(FlightClient::Connect(location, client_options_).Value(&flight_client));
PopulateMetadataSettings(properties);
Expand Down
Loading