From 1fab7c878d55a307e5ef2078801be231b13ebab8 Mon Sep 17 00:00:00 2001 From: "Carpenter, Adam (CORP)" Date: Tue, 30 Nov 2021 12:07:14 -0500 Subject: fix: discourage caching responses with headers --- angelsharkd/src/routes/extensions/simple_search.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'angelsharkd/src/routes/extensions') diff --git a/angelsharkd/src/routes/extensions/simple_search.rs b/angelsharkd/src/routes/extensions/simple_search.rs index 963cb69..b728c1e 100644 --- a/angelsharkd/src/routes/extensions/simple_search.rs +++ b/angelsharkd/src/routes/extensions/simple_search.rs @@ -9,8 +9,10 @@ use std::{ use warp::{ body::{content_length_limit, json}, get, - hyper::StatusCode, - path, post, reply, Filter, Rejection, Reply, + hyper::{header, StatusCode}, + path, post, + reply::{self, with}, + Filter, Rejection, Reply, }; /// Collection of search terms @@ -20,13 +22,14 @@ type Needles = Vec; type HaystackEntries = Vec>; pub fn search(haystack: Haystack) -> impl Filter + Clone { - // TODO: discourage caching response thru headers - path("search") .and(post()) .and(content_length_limit(1024 * 16)) .and(json()) .and_then(move |terms: Needles| handle_search(haystack.to_owned(), terms)) + .with(with::header(header::PRAGMA, "no-cache")) + .with(with::header(header::CACHE_CONTROL, "no-store, max-age=0")) + .with(with::header(header::X_FRAME_OPTIONS, "DENY")) } pub fn refresh(haystack: Haystack) -> impl Filter + Clone { -- cgit v1.2.3