Skip to content

Commit c699f2d

Browse files
fix(ConfigurableMessageHandler): Fix quota project header on retry
1 parent e02d17a commit c699f2d

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

Src/Support/Google.Apis.Auth/OAuth2/AccessTokenWithHeaders.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
using Google.Apis.Util;
1818
using System.Collections.Generic;
1919
using System.Collections.ObjectModel;
20+
using System.Linq;
2021
using System.Net.Http;
2122
using System.Net.Http.Headers;
2223

@@ -78,6 +79,8 @@ public void AddHeaders(HttpRequestHeaders requestHeaders)
7879

7980
foreach (var header in Headers)
8081
{
82+
// Overwite any pre-existing header with the provided values.
83+
requestHeaders.Remove(header.Key);
8184
requestHeaders.Add(header.Key, header.Value);
8285
}
8386
}

Src/Support/Google.Apis.Core/Http/ConfigurableMessageHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,10 @@ bool DisposeAndReturnFalse(IDisposable disposable)
641641
}
642642
}
643643
}
644+
645+
// Reset the quota project here so we can validate a new project isn't specified by the interceptors.
646+
// In any case this will be repopulated by the credential interceptor.
647+
request.Headers.Remove(QuotaProjectHeaderName);
644648
} while (triesRemaining > 0); // Not a successful status code but it was handled.
645649

646650
// If the response is null, we should throw the last exception.

0 commit comments

Comments
 (0)