WinHttpWebSocketCompleteUpgrade function (winhttp.h)

The WinHttpWebSocketCompleteUpgrade function completes a WebSocket handshake started by WinHttpSendRequest.

Syntax

WINHTTPAPI HINTERNET WinHttpWebSocketCompleteUpgrade(
  [in]           HINTERNET hRequest,
  [in, optional] DWORD_PTR pContext
);

Parameters

[in] hRequest

Type: HINTERNET

HTTP request handle used to send a WebSocket handshake.

[in, optional] pContext

Type: DWORD_PTR

Context to be associated with the new handle.

Return value

Type: HINTERNET

A new WebSocket handle. If NULL, call GetLastError to determine the cause of failure.

Remarks

WinHttpWebSocketCompleteUpgrade can be called on an open HTTP request to get a WebSocket handle for performing other WebSocket operations.

The request handle must be marked as a WebSocket upgrade by calling WinHttpSetOption with WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET before sending the request.

The caller should check the HTTP status code returned by the server and call this function only if the status code was 101. Calling it with any other status code will result in a failure.

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps only]
Minimum supported server Windows Server 2012 [desktop apps only]
Target Platform Windows
Header winhttp.h
Library Winhttp.lib
DLL Winhttp.dll