Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache is insensitive to Accept/Content-Type #77

Open
Rdataflow opened this issue Aug 23, 2024 · 0 comments
Open

cache is insensitive to Accept/Content-Type #77

Rdataflow opened this issue Aug 23, 2024 · 0 comments

Comments

@Rdataflow
Copy link

The cache doesn't consider the Accept request header. In some rare edge cases this can lead to the wrong format being sent.

repro steps:

# first query priming the cache
curl https://lindas-cached.test.cluster.ldbar.ch/query -H 'Accept: application/n-quads' --data-raw 'query=DESCRIBE%20%3Chttps%3A%2F%2Fld.admin.ch%2Fcanton%2F2%3E'

# second query reusing the cache - but delivering the wrong format
curl https://lindas-cached.test.cluster.ldbar.ch/query -H 'Accept: application/n-triples' --data-raw 'query=DESCRIBE%20%3Chttps%3A%2F%2Fld.admin.ch%2Fcanton%2F2%3E'

# Alter the hashing method to include POST bodies
# See: https://docs.varnish-software.com/tutorials/caching-post-requests/#step-3-change-the-hashing-function
sub vcl_hash {
hash_data(req.http.Authorization);
hash_data(req.url);
if (req.http.X-Body-Len) {
bodyaccess.hash_req_body();
} else {
hash_data("");
}
return (lookup);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant