Skip to content

Commit 71f9c77

Browse files
trflynn89gmta
authored andcommitted
RequestServer: Remove headers exempted from storage from in-memory cache
We previously excluded headers exempted from storage when we serialized the headers into the database. However, we stored the original headers in-memory. So when a subsequent request hit CacheIndex::find_entry, we would return an entry with response headers that should have been excluded.
1 parent a580392 commit 71f9c77

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Services/RequestServer/Cache/CacheIndex.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ static ByteString serialize_headers(HTTP::HeaderMap const& headers)
1818
StringBuilder builder;
1919

2020
for (auto const& header : headers.headers()) {
21-
if (is_header_exempted_from_storage(header.name))
22-
continue;
23-
2421
builder.append(header.name);
2522
builder.append(':');
2623
builder.append(header.value);
@@ -116,6 +113,15 @@ void CacheIndex::create_entry(u64 cache_key, String url, HTTP::HeaderMap respons
116113
{
117114
auto now = UnixDateTime::now();
118115

116+
for (size_t i = 0; i < response_headers.headers().size();) {
117+
auto const& header = response_headers.headers()[i];
118+
119+
if (is_header_exempted_from_storage(header.name))
120+
response_headers.remove(header.name);
121+
else
122+
++i;
123+
}
124+
119125
Entry entry {
120126
.cache_key = cache_key,
121127
.url = move(url),

0 commit comments

Comments
 (0)