Skip to content

Commit

Permalink
Fall back from secure to insecure send only if context was not cancelled
Browse files Browse the repository at this point in the history
or timed out.
  • Loading branch information
jwlv committed Nov 24, 2024
1 parent 93d5595 commit 05948d2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/trs_http_api/trshttp_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,9 @@ func ExecuteTask(tloc *TRSHTTPLocal, tct taskChannelTuple) {
tloc.Logger.Tracef("Using secure client to send request")
tct.task.Request.Response, tmpError = cpack.secure.Do(req)

//If the error is a TLS error, fall back to insecure and log it.
if (tmpError != nil) {
// Fall back to insecure only if the enclosing context was not
// cancelled or timed out.
if (tmpError != nil && tct.task.context.Err() != nil {
// But first make sure we drain/close the body of the failed
// response, if there was one
if tct.task.Request.Response != nil && tct.task.Request.Response.Body != nil {
Expand All @@ -616,6 +617,9 @@ func ExecuteTask(tloc *TRSHTTPLocal, tct taskChannelTuple) {
tloc.Logger.Tracef("No response received")
}

// TODO: Consider cancelling the context for this task here instead of
// leaving it up to the caller

tct.taskListChannel <- tct.task
}

Expand Down

0 comments on commit 05948d2

Please sign in to comment.