Zebediah Figura : httpapi: Implement HttpCreateServerSession() and HttpCloseServerSession().
Alexandre Julliard
julliard at winehq.org
Thu Aug 29 15:05:50 CDT 2019
Module: wine
Branch: master
Commit: 76eb42a76068f976477753b7e138e0b1cb60bd44
URL: https://source.winehq.org/git/wine.git/?a=commit;h=76eb42a76068f976477753b7e138e0b1cb60bd44
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed Aug 28 20:45:30 2019 -0500
httpapi: Implement HttpCreateServerSession() and HttpCloseServerSession().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/httpapi/httpapi_main.c | 56 +++++++++++++++++++++++++++++++++++++++-----
dlls/httpapi/tests/httpapi.c | 7 ------
include/http.h | 2 +-
3 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/dlls/httpapi/httpapi_main.c b/dlls/httpapi/httpapi_main.c
index c970c68..a71dcc5 100644
--- a/dlls/httpapi/httpapi_main.c
+++ b/dlls/httpapi/httpapi_main.c
@@ -23,6 +23,7 @@
#include "winternl.h"
#include "wine/debug.h"
#include "wine/heap.h"
+#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(httpapi);
@@ -470,20 +471,63 @@ ULONG WINAPI HttpSendHttpResponse(HANDLE queue, HTTP_REQUEST_ID id, ULONG flags,
return ret;
}
+struct server_session
+{
+ struct list entry;
+};
+
+static struct list server_sessions = LIST_INIT(server_sessions);
+
+static struct server_session *get_server_session(HTTP_SERVER_SESSION_ID id)
+{
+ struct server_session *session;
+ LIST_FOR_EACH_ENTRY(session, &server_sessions, struct server_session, entry)
+ {
+ if ((HTTP_SERVER_SESSION_ID)(ULONG_PTR)session == id)
+ return session;
+ }
+ return NULL;
+}
+
/***********************************************************************
* HttpCreateServerSession (HTTPAPI.@)
*/
-ULONG WINAPI HttpCreateServerSession( HTTPAPI_VERSION version, HTTP_SERVER_SESSION_ID *id, ULONG reserved )
+ULONG WINAPI HttpCreateServerSession(HTTPAPI_VERSION version, HTTP_SERVER_SESSION_ID *id, ULONG reserved)
{
- FIXME( "({%d,%d}, %p, %d): stub!\n", version.HttpApiMajorVersion, version.HttpApiMinorVersion, id, reserved );
- return ERROR_ACCESS_DENIED;
+ struct server_session *session;
+
+ TRACE("version %u.%u, id %p, reserved %u.\n", version.HttpApiMajorVersion,
+ version.HttpApiMinorVersion, id, reserved);
+
+ if (!id)
+ return ERROR_INVALID_PARAMETER;
+
+ if ((version.HttpApiMajorVersion != 1 && version.HttpApiMajorVersion != 2)
+ || version.HttpApiMinorVersion)
+ return ERROR_REVISION_MISMATCH;
+
+ if (!(session = heap_alloc(sizeof(*session))))
+ return ERROR_OUTOFMEMORY;
+
+ list_add_tail(&server_sessions, &session->entry);
+
+ *id = (ULONG_PTR)session;
+ return ERROR_SUCCESS;
}
/***********************************************************************
* HttpCloseServerSession (HTTPAPI.@)
*/
-ULONG WINAPI HttpCloseServerSession( HTTP_SERVER_SESSION_ID id )
+ULONG WINAPI HttpCloseServerSession(HTTP_SERVER_SESSION_ID id)
{
- FIXME( "(%s): stub!\n", wine_dbgstr_longlong(id));
- return ERROR_INVALID_PARAMETER;
+ struct server_session *session;
+
+ TRACE("id %s.\n", wine_dbgstr_longlong(id));
+
+ if (!(session = get_server_session(id)))
+ return ERROR_INVALID_PARAMETER;
+
+ list_remove(&session->entry);
+ heap_free(session);
+ return ERROR_SUCCESS;
}
diff --git a/dlls/httpapi/tests/httpapi.c b/dlls/httpapi/tests/httpapi.c
index 94804a9..2153361 100644
--- a/dlls/httpapi/tests/httpapi.c
+++ b/dlls/httpapi/tests/httpapi.c
@@ -888,37 +888,30 @@ static void test_HttpCreateServerSession(void)
version.HttpApiMajorVersion = 1;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, NULL, 0);
-todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
version.HttpApiMajorVersion = 1;
version.HttpApiMinorVersion = 1;
ret = pHttpCreateServerSession(version, &session, 0);
-todo_wine
ok(ret == ERROR_REVISION_MISMATCH, "Unexpected return value %u.\n", ret);
version.HttpApiMajorVersion = 3;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, &session, 0);
-todo_wine
ok(ret == ERROR_REVISION_MISMATCH, "Unexpected return value %u.\n", ret);
version.HttpApiMajorVersion = 2;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, &session, 0);
-todo_wine
ok(!ret, "Unexpected return value %u.\n", ret);
ret = pHttpCloseServerSession(session);
-todo_wine
ok(!ret, "Unexpected return value %u.\n", ret);
version.HttpApiMajorVersion = 1;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, &session, 0);
-todo_wine
ok(!ret, "Unexpected return value %u.\n", ret);
ret = pHttpCloseServerSession(session);
-todo_wine
ok(!ret, "Unexpected return value %u.\n", ret);
ret = pHttpCloseServerSession(0xdead);
diff --git a/include/http.h b/include/http.h
index 84d3445..dc4af74 100644
--- a/include/http.h
+++ b/include/http.h
@@ -398,9 +398,9 @@ typedef struct _HTTP_LOG_DATA
} HTTP_LOG_DATA, *PHTTP_LOG_DATA;
ULONG WINAPI HttpAddUrl(HANDLE,PCWSTR,PVOID);
+ULONG WINAPI HttpCloseServerSession(HTTP_SERVER_SESSION_ID id);
ULONG WINAPI HttpCreateHttpHandle(PHANDLE,ULONG);
ULONG WINAPI HttpCreateServerSession(HTTPAPI_VERSION,PHTTP_SERVER_SESSION_ID,ULONG);
-ULONG WINAPI HttpCloseServerSession(HTTP_SERVER_SESSION_ID);
ULONG WINAPI HttpDeleteServiceConfiguration(HANDLE,HTTP_SERVICE_CONFIG_ID,PVOID,ULONG,LPOVERLAPPED);
ULONG WINAPI HttpInitialize(HTTPAPI_VERSION version, ULONG flags, void *reserved);
ULONG WINAPI HttpTerminate(ULONG flags, void *reserved);
More information about the wine-cvs
mailing list