MCPcopy Create free account
hub / github.com/apache/arrow / StartCall

Method StartCall

cpp/src/arrow/flight/sql/server_session_middleware.cc:137–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137Status ServerSessionMiddlewareFactory::StartCall(
138 const CallInfo&, const ServerCallContext& context,
139 std::shared_ptr<ServerMiddleware>* middleware) {
140 std::string session_id;
141
142 const std::pair<CallHeaders::const_iterator, CallHeaders::const_iterator>&
143 headers_it_pr = context.incoming_headers().equal_range("cookie");
144 for (auto itr = headers_it_pr.first; itr != headers_it_pr.second; ++itr) {
145 const std::string_view& cookie_header = itr->second;
146 const std::vector<std::pair<std::string, std::string>> cookies =
147 ParseCookieString(cookie_header);
148 for (const std::pair<std::string, std::string>& cookie : cookies) {
149 if (cookie.first == kSessionCookieName) {
150 if (cookie.second.empty())
151 return Status::Invalid("Empty ", kSessionCookieName, " cookie value.");
152 session_id = std::move(cookie.second);
153 }
154 }
155 if (!session_id.empty()) break;
156 }
157
158 if (session_id.empty()) {
159 // No cookie was found
160 // Temporary workaround until middleware handling fixed
161 auto [id, s] = CreateNewSession();
162 *middleware = std::make_shared<ServerSessionMiddlewareImpl>(
163 this, context.incoming_headers(), std::move(s), id, false);
164 } else {
165 const std::shared_lock<std::shared_mutex> l(session_store_lock_);
166 if (auto it = session_store_.find(session_id); it == session_store_.end()) {
167 return Status::Invalid("Invalid or expired ", kSessionCookieName, " cookie.");
168 } else {
169 auto session = it->second;
170 *middleware = std::make_shared<ServerSessionMiddlewareImpl>(
171 this, context.incoming_headers(), std::move(session), session_id);
172 }
173 }
174
175 return Status::OK();
176}
177
178/// \brief Get a new, empty session option map & its id key; {"",NULLPTR} on collision.
179std::pair<std::string, std::shared_ptr<FlightSession>>

Callers 3

GetFlightInfoAsyncMethod · 0.45
MakeCallContextMethod · 0.45

Calls 6

incoming_headersMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected