Skip to content

Commit 39ff74d

Browse files
maikebingCopilot
andauthored
Update NGitLab/Impl/HttpRequestor.GitLabRequest.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5d56ad3 commit 39ff74d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

NGitLab/Impl/HttpRequestor.GitLabRequest.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,23 @@ private async Task<HttpResponseMessage> GetResponseImplAsync(RequestOptions opti
115115
private HttpRequestMessage CreateRequest(RequestOptions options)
116116
{
117117
var request = new HttpRequestMessage(new HttpMethod(Method.ToString().ToUpperInvariant()), Url);
118-
if (HasOutput)
118+
// Copy headers from Headers property to request
119+
if (Headers != null)
119120
{
121+
foreach (var key in Headers.AllKeys)
122+
{
123+
var values = Headers.GetValues(key);
124+
if (!request.Headers.TryAddWithoutValidation(key, values))
125+
{
126+
// If it fails to add as a request header, it might be a content header
127+
if (request.Content != null)
128+
{
129+
request.Content.Headers.TryAddWithoutValidation(key, values);
130+
}
131+
}
132+
}
133+
}
134+
if (HasOutput)
120135
if (FormData != null)
121136
{
122137
AddFileData(request, options);

0 commit comments

Comments
 (0)