Skip to content

Commit 11e2b32

Browse files
authored
chore(logging): update logging remote constraint ETag caching (#3494)
* chore(logging): update logging remote constraint ETag caching * chore: add code comment
1 parent 6444f3a commit 11e2b32

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin/Configuration/DefaultRemoteLoggingConstraintsProvider.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,14 @@ public class DefaultRemoteLoggingConstraintsProvider: RemoteLoggingConstraintsPr
5858
let loggingConstraint = try JSONDecoder().decode(LoggingConstraints.self, from: data)
5959
loggingConstraintsLocalStore.setLocalLoggingConstraints(loggingConstraints: loggingConstraint)
6060

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

0 commit comments

Comments
 (0)