@@ -371,7 +371,7 @@ fn perform(self: *Client, timeout_ms: c_int) !void {
371371 const transfer = try Transfer .fromEasy (easy );
372372
373373 // In case of auth challenge
374- if (transfer ._auth_challenge != null ) {
374+ if (transfer ._auth_challenge != null and transfer . _tries < 10 ) { // TODO give a way to configure the number of auth retries.
375375 if (transfer .client .notification ) | notification | {
376376 var wait_for_interception = false ;
377377 notification .dispatch (.http_request_auth_required , &.{ .transfer = transfer , .wait_for_interception = & wait_for_interception });
@@ -643,6 +643,21 @@ pub const Transfer = struct {
643643 _redirecting : bool = false ,
644644 _auth_challenge : ? AuthChallenge = null ,
645645
646+ // number of times the transfer has been tried.
647+ // incremented by reset func.
648+ _tries : u8 = 0 ,
649+
650+ pub fn reset (self : * Transfer ) void {
651+ self ._redirecting = false ;
652+ self ._auth_challenge = null ;
653+ self ._notified_fail = false ;
654+ self ._header_done_called = false ;
655+ self .response_header = null ;
656+ self .bytes_received = 0 ;
657+
658+ self ._tries += 1 ;
659+ }
660+
646661 fn deinit (self : * Transfer ) void {
647662 self .req .headers .deinit ();
648663 if (self ._handle ) | handle | {
0 commit comments