@@ -372,10 +372,21 @@ fn perform(self: *Client, timeout_ms: c_int) !void {
372372 const easy = msg .easy_handle .? ;
373373 const transfer = try Transfer .fromEasy (easy );
374374
375+ var code : c_long = undefined ;
376+ try errorCheck (c .curl_easy_getinfo (easy , c .CURLINFO_RESPONSE_CODE , & code ));
377+ std .debug .print ("FAILED REQ: {any}\n " , .{code });
378+
375379 // release it ASAP so that it's available; some done_callbacks
376380 // will load more resources.
377381 self .endTransfer (transfer );
378382
383+ // If the transfer is waiting for auth challenge interception, don't
384+ // deinit the transfer and don't call the callbacks. All will be done
385+ // later during the interception's response.
386+ if (transfer ._auth_challenge ) {
387+ continue ;
388+ }
389+
379390 defer transfer .deinit ();
380391
381392 if (errorCheck (msg .data .result )) {
@@ -577,7 +588,9 @@ pub const Transfer = struct {
577588 _handle : ? * Handle = null ,
578589
579590 _redirecting : bool = false ,
580- _forbidden : bool = false ,
591+ // True when a request returns a 401 or 407 and we wait for a request
592+ // interception to continue with auth.
593+ _auth_challenge : bool = false ,
581594
582595 // use_proxy is set when the transfer has been associated to a given
583596 // connection in makeRequest().
@@ -807,6 +820,7 @@ pub const Transfer = struct {
807820 var wait_for_interception = false ;
808821 notification .dispatch (.http_request_auth_required , &.{ .transfer = transfer , .wait_for_interception = & wait_for_interception });
809822 if (wait_for_interception ) {
823+ transfer ._auth_challenge = true ;
810824 // The user is send an invitation to intercept this request.
811825 return buf_len ;
812826 }
@@ -841,7 +855,7 @@ pub const Transfer = struct {
841855 return c .CURL_WRITEFUNC_ERROR ;
842856 };
843857
844- if (transfer ._redirecting ) {
858+ if (transfer ._redirecting or transfer . _auth_challenge ) {
845859 return chunk_len ;
846860 }
847861
0 commit comments