Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Removed dead code: SafeWinHttpHandleWithCallback (#28171)
Browse files Browse the repository at this point in the history
Removed dead code:
* SafeWinHttpHandleWithCallback (fixes #2501)
* Interop.winhttp DllImports that are no longer used
  • Loading branch information
Robert Matusewicz authored and karelz committed Mar 18, 2018
1 parent 7962d85 commit 7153ea1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ internal partial class Interop
{
internal partial class WinHttp
{
// Issue 2501: Fold SafeWinHttpHandleWithCallback and SafeWinHttpHandle into a single type.
// SafeWinHttpHandleWithCallback is incorrectly overriding the Dispose(bool disposing) method
// and will be fixed as part of merging the classes.
internal class SafeWinHttpHandle : SafeHandleZeroOrMinusOneIsInvalid
{
private SafeWinHttpHandle _parentHandle = null;
Expand Down Expand Up @@ -59,43 +56,5 @@ protected override bool ReleaseHandle()
return Interop.WinHttp.WinHttpCloseHandle(handle);
}
}

internal sealed class SafeWinHttpHandleWithCallback : SafeWinHttpHandle
{
// Add a reference to this object so that the AppDomain doesn't get unloaded before the last WinHttp callback.
public void AttachCallback()
{
bool ignore = false;
DangerousAddRef(ref ignore);
}

public void DetachCallback()
{
DangerousRelease();
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
// We need to initiate the asynchronous process of closing the WinHttp handle:
// 1. Ensure that all other WinHttp function calls for this handle have returned.
// 2. Call WinHttpCloseHandle.
// 3. Wait for WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING in the callback.
// On this event, call DetachCallback.
//
// WinHttp guarantees that no other calls to the callback are made for this handle after
// WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING has been received.
// Holding the reference to the SafeHandle object ensures that the appdomain where the SafeHandle
// lives until it is guaranteed that no further callback calls are made from the native (WinHttp) side.
Interop.WinHttp.WinHttpCloseHandle(handle);
}
}

protected override bool ReleaseHandle()
{
return base.ReleaseHandle();
}
}
}
}
75 changes: 0 additions & 75 deletions src/Common/src/Interop/Windows/winhttp/Interop.winhttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ public static extern SafeWinHttpHandle WinHttpConnect(
ushort serverPort,
uint reserved);

// NOTE: except for the return type, this refers to the same function as WinHttpConnect.
[DllImport(Interop.Libraries.WinHttp, EntryPoint = "WinHttpConnect", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeWinHttpHandleWithCallback WinHttpConnectWithCallback(
SafeWinHttpHandle sessionHandle,
string serverName,
ushort serverPort,
uint reserved);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeWinHttpHandle WinHttpOpenRequest(
SafeWinHttpHandle connectHandle,
Expand All @@ -47,17 +39,6 @@ public static extern SafeWinHttpHandle WinHttpOpenRequest(
string acceptTypes,
uint flags);

// NOTE: except for the return type, this refers to the same function as WinHttpOpenRequest.
[DllImport(Interop.Libraries.WinHttp, EntryPoint = "WinHttpOpenRequest", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeWinHttpHandleWithCallback WinHttpOpenRequestWithCallback(
SafeWinHttpHandle connectHandle,
string verb,
string objectName,
string version,
string referrer,
string acceptTypes,
uint flags);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool WinHttpAddRequestHeaders(
Expand Down Expand Up @@ -256,61 +237,5 @@ public static extern IntPtr WinHttpSetStatusCallback(
WINHTTP_STATUS_CALLBACK callback,
uint notificationFlags,
IntPtr reserved);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeWinHttpHandleWithCallback WinHttpWebSocketCompleteUpgrade(
SafeWinHttpHandle requestHandle,
IntPtr context);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = false)]
public static extern uint WinHttpWebSocketSend(
SafeWinHttpHandle webSocketHandle,
WINHTTP_WEB_SOCKET_BUFFER_TYPE bufferType,
IntPtr buffer,
uint bufferLength);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = false)]
public static extern uint WinHttpWebSocketReceive(
SafeWinHttpHandle webSocketHandle,
IntPtr buffer,
uint bufferLength,
out uint bytesRead,
out WINHTTP_WEB_SOCKET_BUFFER_TYPE bufferType);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = false)]
public static extern uint WinHttpWebSocketShutdown(
SafeWinHttpHandle webSocketHandle,
ushort status,
byte[] reason,
uint reasonLength);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = false)]
public static extern uint WinHttpWebSocketShutdown(
SafeWinHttpHandle webSocketHandle,
ushort status,
IntPtr reason,
uint reasonLength);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = false)]
public static extern uint WinHttpWebSocketClose(
SafeWinHttpHandle webSocketHandle,
ushort status,
byte[] reason,
uint reasonLength);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = false)]
public static extern uint WinHttpWebSocketClose(
SafeWinHttpHandle webSocketHandle,
ushort status,
IntPtr reason,
uint reasonLength);

[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = false)]
public static extern uint WinHttpWebSocketQueryCloseStatus(
SafeWinHttpHandle webSocketHandle,
out ushort status,
byte[] reason,
uint reasonLength,
out uint reasonLengthConsumed);
}
}

0 comments on commit 7153ea1

Please sign in to comment.