Skip to content

Commit

Permalink
log a warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis committed Apr 18, 2024
1 parent a5aeb65 commit 3d9959d
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
*/
package aws.sdk.kotlin.services.s3.internal

import aws.smithy.kotlin.runtime.awsprotocol.ClockSkewInterceptor
import aws.smithy.kotlin.runtime.client.ProtocolResponseInterceptorContext
import aws.smithy.kotlin.runtime.http.interceptors.HttpInterceptor
import aws.smithy.kotlin.runtime.http.request.HttpRequest
import aws.smithy.kotlin.runtime.http.request.toBuilder
import aws.smithy.kotlin.runtime.http.response.HttpResponse
import aws.smithy.kotlin.runtime.http.response.toBuilder
import aws.smithy.kotlin.runtime.telemetry.logging.logger
import aws.smithy.kotlin.runtime.time.Instant
import kotlin.coroutines.coroutineContext

/**
* Interceptor to handle special-cased `Expires` field which must not cause deserialization to fail.
Expand All @@ -26,6 +29,9 @@ internal object ExpiresFieldInterceptor : HttpInterceptor {
try {
Instant.fromRfc5322(response.headers["Expires"]!!)
} catch (e: Exception) {
coroutineContext.logger<ExpiresFieldInterceptor>().warn {
"Failed to parse `expires`=${response.headers["Expires"]} as a timestamp, setting it to `null`. The unparsed value is available in `expiresString`."
}
response.headers.remove("Expires")
}
}
Expand Down

0 comments on commit 3d9959d

Please sign in to comment.