Closed muuvmuuv closed 9 months ago
Tested, and it works by modifing HttpCacheLocalStorage
.
get(key) {
const cacheValue = super.get(createKey$2(key));
if (cacheValue) {
return cacheValue;
}
const value = storage.getItem(createKey$2(key));
if (value) {
const response = new HttpResponse(value)
response.headers = new HttpHeaders(value.headers);
super.set(createKey$2(key), response);
}
return super.get(createKey$2(key));
}
set(key, response) {
const httpResponse = {...response, headers: {} }
if (response.headers instanceof HttpHeaders) {
response.headers.keys().forEach(key => {
httpResponse.headers[key] = response.headers.get(key);
});
}
storage.setItem(createKey$2(key), httpResponse);
return super.set(createKey$2(key), httpResponse);
}
I'm submitting a...
Current behavior
I am not seeing HttpHeaders beeing saved or received in cache.
Expected behavior
HttpHeaders should be serialized as HttpHeaders otherwise a
.get()
wont longer work in interceptors.Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
We have request and correlation ids set in backend in response headers that I put into the response body for better access in templates. This is done in an interceptor.
Environment