Skip to content

Commit 341ee6e

Browse files
committed
add value check for the show_cached and cache_results headers
1 parent 77a7241 commit 341ee6e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

server/src/handlers/http/query.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,13 @@ pub async fn put_results_in_cache(
197197
Ok(())
198198
}
199199
// do cache
200-
(Some(_), Some(query_cache_manager)) => {
200+
(Some(should_cache), Some(query_cache_manager)) => {
201+
202+
if should_cache != "true" {
203+
log::error!("value of cache results header is false");
204+
return Err(QueryError::CacheError(CacheError::Other("should not cache results")));
205+
}
206+
201207
let user_id = user_id.ok_or(CacheError::Other("User Id not provided"))?;
202208

203209
if let Err(err) = query_cache_manager
@@ -241,7 +247,12 @@ pub async fn get_results_from_cache(
241247
);
242248
None
243249
}
244-
(Some(_), Some(query_cache_manager)) => {
250+
(Some(should_show), Some(query_cache_manager)) => {
251+
if should_show != "true" {
252+
log::error!("value of show cached header is false");
253+
return Err(QueryError::CacheError(CacheError::Other("should not return cached results")));
254+
}
255+
245256
let user_id =
246257
user_id.ok_or_else(|| QueryError::Anyhow(anyhow!("User Id not provided")))?;
247258

0 commit comments

Comments
 (0)