Skip to content

Commit

Permalink
[WinHTTP] Remove unnecessary recursion (#112698)
Browse files Browse the repository at this point in the history
* Remove unnecessary recursion

* Feedback - refetch the last error

* Fix
  • Loading branch information
ManickaP authored Feb 20, 2025
1 parent 59414b5 commit 972b621
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,16 @@ public static unsafe bool GetResponseHeader(
index = originalIndex;

buffer = new char[bufferLength];
return GetResponseHeader(requestHandle, infoLevel, ref buffer, ref index, out headerValue);
fixed (char* pBuffer = &buffer[0])
{
if (QueryHeaders(requestHandle, infoLevel, pBuffer, ref bufferLength, ref index))
{
headerValue = new string(pBuffer, 0, bufferLength);
return true;
}
}

lastError = Marshal.GetLastWin32Error();
}

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

0 comments on commit 972b621

Please sign in to comment.