Skip to content

Commit

Permalink
fix: Cancel the previous request before scheduling a new one in HTTP …
Browse files Browse the repository at this point in the history
…resumer

The `http::Client()` class is designed to always have only one
HTTP request in progress. Thus, before scheduling a new request
using the same `http::Client` instance, cancel the previous
request to make sure everything is properly reset for the new
one.

Ticket: MEN-7810
Changelog: Fix download resuming to reset the HTTP state and
avoid repeatedly hitting the same error in case of a bad state

Signed-off-by: Vratislav Podzimek <[email protected]>
  • Loading branch information
vpodzime committed Dec 11, 2024
1 parent 9ef1299 commit 189c667
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/http/http_resumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ http::OutgoingRequestPtr DownloadResumerClient::RemainingRangeRequest() const {
};

error::Error DownloadResumerClient::ScheduleNextResumeRequest() {
// In any case, make sure the previous HTTP request is cancelled.
client_.Cancel();

auto exp_interval = retry_.backoff.NextInterval();
if (!exp_interval) {
return http::MakeError(
Expand Down

0 comments on commit 189c667

Please sign in to comment.