Skip to content

Commit 972b621

Browse files
authored
[WinHTTP] Remove unnecessary recursion (#112698)
* Remove unnecessary recursion * Feedback - refetch the last error * Fix
1 parent 59414b5 commit 972b621

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseParser.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,16 @@ public static unsafe bool GetResponseHeader(
187187
index = originalIndex;
188188

189189
buffer = new char[bufferLength];
190-
return GetResponseHeader(requestHandle, infoLevel, ref buffer, ref index, out headerValue);
190+
fixed (char* pBuffer = &buffer[0])
191+
{
192+
if (QueryHeaders(requestHandle, infoLevel, pBuffer, ref bufferLength, ref index))
193+
{
194+
headerValue = new string(pBuffer, 0, bufferLength);
195+
return true;
196+
}
197+
}
198+
199+
lastError = Marshal.GetLastWin32Error();
191200
}
192201

193202
throw WinHttpException.CreateExceptionUsingError(lastError, nameof(Interop.WinHttp.WinHttpQueryHeaders));

0 commit comments

Comments
 (0)