public static GetResponseHeader ( Interop.WinHttp.SafeWinHttpHandle requestHandle, uint infoLevel, char &buffer, uint &index, string &headerValue ) : bool | ||
requestHandle | Interop.WinHttp.SafeWinHttpHandle | |
infoLevel | uint | |
buffer | char | |
index | uint | |
headerValue | string | |
return | bool |
public static void AddResponseCookiesToContainer(WinHttpRequestState state) { HttpRequestMessage request = state.RequestMessage; SafeWinHttpHandle requestHandle = state.RequestHandle; CookieContainer cookieContainer = state.Handler.CookieContainer; Debug.Assert(state.Handler.CookieUsePolicy == CookieUsePolicy.UseSpecifiedCookieContainer); Debug.Assert(cookieContainer != null); // Get 'Set-Cookie' headers from response. char[] buffer = null; uint index = 0; string cookieHeader; while (WinHttpResponseParser.GetResponseHeader( requestHandle, Interop.WinHttp.WINHTTP_QUERY_SET_COOKIE, ref buffer, ref index, out cookieHeader)) { try { cookieContainer.SetCookies(request.RequestUri, cookieHeader); if (NetEventSource.Log.IsEnabled()) { NetEventSource.Info(cookieContainer, $"Added cookie: {cookieHeader}"); } } catch (CookieException) { // We ignore malformed cookies in the response. if (NetEventSource.Log.IsEnabled()) { NetEventSource.Error(cookieContainer, $"Ignoring invalid cookie: {cookieHeader}"); } } } }
public static void AddResponseCookiesToContainer(WinHttpRequestState state) { HttpRequestMessage request = state.RequestMessage; SafeWinHttpHandle requestHandle = state.RequestHandle; CookieContainer cookieContainer = state.Handler.CookieContainer; Debug.Assert(state.Handler.CookieUsePolicy == CookieUsePolicy.UseSpecifiedCookieContainer); Debug.Assert(cookieContainer != null); // Get 'Set-Cookie' headers from response. char[] buffer = null; uint index = 0; string cookieHeader; WinHttpTraceHelper.Trace("WINHTTP_QUERY_SET_COOKIE"); while (WinHttpResponseParser.GetResponseHeader( requestHandle, Interop.WinHttp.WINHTTP_QUERY_SET_COOKIE, ref buffer, ref index, out cookieHeader)) { WinHttpTraceHelper.Trace(cookieHeader); try { cookieContainer.SetCookies(request.RequestUri, cookieHeader); WinHttpTraceHelper.Trace(cookieHeader); } catch (CookieException) { // We ignore malformed cookies in the response. WinHttpTraceHelper.Trace("Ignoring invalid cookie: {0}", cookieHeader); } } }