[PATCH 2/2] winhttp: Support WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET option
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> --- dlls/winhttp/session.c | 4 ++++ dlls/winhttp/tests/winhttp.c | 2 +- dlls/winhttp/winhttp_private.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c index 24455d858a..0586656884 100644 --- a/dlls/winhttp/session.c +++ b/dlls/winhttp/session.c @@ -1042,6 +1042,10 @@ static BOOL request_set_option( struct object_header *hdr, DWORD option, void *b FIXME("WINHTTP_OPTION_CONNECT_RETRIES\n"); return TRUE; + case WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET: + request->websocket_state = WEBSOCKET_UPGRADING; + return TRUE; + default: FIXME("unimplemented option %u\n", option); SetLastError( ERROR_WINHTTP_INVALID_OPTION ); diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index f08f50b9a9..e17639d4dd 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -3119,7 +3119,7 @@ static void test_websocket(int port) ok(request != NULL, "got %u\n", GetLastError()); ret = WinHttpSetOption(request, WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET, NULL, 0); - todo_wine ok(ret, "got %u\n", GetLastError()); + ok(ret, "got %u\n", GetLastError()); size = sizeof(header); SetLastError(0xdeadbeef); diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index 657f82f642..35a1daf063 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -154,6 +154,15 @@ struct authinfo BOOL finished; /* finished authenticating */ }; +enum websocket_state +{ + WEBSOCKET_NOT_SUPPORTED, + WEBSOCKET_UPGRADING, + WEBSOCKET_OPEN, + WEBSOCKET_CLOSING, + WEBSOCKET_CLOSED, +}; + struct request { struct object_header hdr; @@ -167,6 +176,7 @@ struct request struct netconn *netconn; DWORD security_flags; BOOL check_revocation; + enum websocket_state websocket_state; const CERT_CONTEXT *server_cert; const CERT_CONTEXT *client_cert; CredHandle cred_handle; -- 2.27.0
On Wed, 2020-06-17 at 15:34 +1000, Alistair Leslie-Hughes wrote:
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index 657f82f642..35a1daf063 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -154,6 +154,15 @@ struct authinfo BOOL finished; /* finished authenticating */ };
+enum websocket_state +{ + WEBSOCKET_NOT_SUPPORTED, + WEBSOCKET_UPGRADING, + WEBSOCKET_OPEN, + WEBSOCKET_CLOSING, + WEBSOCKET_CLOSED, +};
I'm not convinced we need a state tracking variable. I've submitted an implementation of WinHttpWebSocketCompleteUpgrade that uses a simple flag.
participants (2)
-
Alistair Leslie-Hughes -
Hans Leidekker