Skip to content

Commit

Permalink
chore(logging): update logging remote constraint ETag caching (#3494)
Browse files Browse the repository at this point in the history
* chore(logging): update logging remote constraint ETag caching

* chore: add code comment
  • Loading branch information
phantumcode authored Feb 2, 2024
1 parent 6444f3a commit 11e2b32
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ public class DefaultRemoteLoggingConstraintsProvider: RemoteLoggingConstraintsPr
let loggingConstraint = try JSONDecoder().decode(LoggingConstraints.self, from: data)
loggingConstraintsLocalStore.setLocalLoggingConstraints(loggingConstraints: loggingConstraint)

if let etag = (response as? HTTPURLResponse)?.value(forHTTPHeaderField: "If-None-Match") {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
// the response header should only use the ETag header field in accordance with Http protocol spec
// but we need to also look at `If-None-Match` due to the initial/old lambda documentation recommending to
// `If-None-Match` to return the ETag
if let etag = (response as? HTTPURLResponse)?.value(forHTTPHeaderField: "ETag") {
loggingConstraintsLocalStore.setLocalLoggingConstraintsEtag(etag: etag)
} else if let etag = (response as? HTTPURLResponse)?.value(forHTTPHeaderField: "If-None-Match") {
loggingConstraintsLocalStore.setLocalLoggingConstraintsEtag(etag: etag)
}
return loggingConstraint
Expand Down

0 comments on commit 11e2b32

Please sign in to comment.