Zebediah Figura : httpapi: Start the http service in HttpInitialize().
Alexandre Julliard
julliard at winehq.org
Thu Aug 29 15:05:50 CDT 2019
Module: wine
Branch: master
Commit: efacf6f455b42721c2edb15a06ef57755342fb0b
URL: https://source.winehq.org/git/wine.git/?a=commit;h=efacf6f455b42721c2edb15a06ef57755342fb0b
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed Aug 28 20:45:29 2019 -0500
httpapi: Start the http service in HttpInitialize().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38245
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/httpapi/Makefile.in | 1 +
dlls/httpapi/httpapi_main.c | 39 +++++++++++++++++++++++++++++++++++----
dlls/httpapi/tests/httpapi.c | 24 ++++++++----------------
3 files changed, 44 insertions(+), 20 deletions(-)
diff --git a/dlls/httpapi/Makefile.in b/dlls/httpapi/Makefile.in
index b3af7da..6a55f84 100644
--- a/dlls/httpapi/Makefile.in
+++ b/dlls/httpapi/Makefile.in
@@ -1,5 +1,6 @@
MODULE = httpapi.dll
IMPORTLIB = httpapi
+IMPORTS = advapi32
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/httpapi/httpapi_main.c b/dlls/httpapi/httpapi_main.c
index 8a970a0..c970c68 100644
--- a/dlls/httpapi/httpapi_main.c
+++ b/dlls/httpapi/httpapi_main.c
@@ -19,6 +19,7 @@
*/
#include "wine/http.h"
+#include "winsvc.h"
#include "winternl.h"
#include "wine/debug.h"
#include "wine/heap.h"
@@ -52,11 +53,41 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID lpv )
* NO_ERROR if function succeeds, or error code if function fails
*
*/
-ULONG WINAPI HttpInitialize( HTTPAPI_VERSION version, ULONG flags, PVOID reserved )
+ULONG WINAPI HttpInitialize(HTTPAPI_VERSION version, ULONG flags, void *reserved)
{
- FIXME( "({%d,%d}, 0x%x, %p): stub!\n", version.HttpApiMajorVersion,
- version.HttpApiMinorVersion, flags, reserved );
- return NO_ERROR;
+ static const WCHAR httpW[] = {'h','t','t','p',0};
+ SC_HANDLE manager, service;
+
+ TRACE("version %u.%u, flags %#x, reserved %p.\n", version.HttpApiMajorVersion,
+ version.HttpApiMinorVersion, flags, reserved);
+
+ if (flags & ~HTTP_INITIALIZE_SERVER)
+ {
+ FIXME("Unhandled flags %#x.\n", flags);
+ return ERROR_CALL_NOT_IMPLEMENTED;
+ }
+
+ if (!(manager = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT)))
+ return GetLastError();
+
+ if (!(service = OpenServiceW(manager, httpW, SERVICE_START)))
+ {
+ ERR("Failed to open HTTP service, error %u.\n", GetLastError());
+ CloseServiceHandle(manager);
+ return GetLastError();
+ }
+
+ if (!StartServiceW(service, 0, NULL) && GetLastError() != ERROR_SERVICE_ALREADY_RUNNING)
+ {
+ ERR("Failed to start HTTP service, error %u.\n", GetLastError());
+ CloseServiceHandle(service);
+ CloseServiceHandle(manager);
+ return GetLastError();
+ }
+
+ CloseServiceHandle(service);
+ CloseServiceHandle(manager);
+ return ERROR_SUCCESS;
}
/***********************************************************************
diff --git a/dlls/httpapi/tests/httpapi.c b/dlls/httpapi/tests/httpapi.c
index c30c380..94804a9 100644
--- a/dlls/httpapi/tests/httpapi.c
+++ b/dlls/httpapi/tests/httpapi.c
@@ -122,8 +122,7 @@ static void test_v1_server(void)
/* Non-zero reserved parameter is accepted on XP/2k3. */
queue = NULL;
ret = HttpCreateHttpHandle(&queue, 0);
- todo_wine ok(!ret, "Unexpected ret value %u.\n", ret);
- if (ret) return;
+ ok(!ret, "Unexpected ret value %u.\n", ret);
ok(!!queue, "Unexpected handle value %p.\n", queue);
queue2 = NULL;
@@ -314,8 +313,7 @@ static void test_v1_completion_port(void)
ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
ret = HttpCreateHttpHandle(&queue, 0);
- todo_wine ok(!ret, "Got error %u.\n", ret);
- if (ret) return;
+ ok(!ret, "Got error %u.\n", ret);
port = CreateIoCompletionPort(queue, NULL, 123, 0);
ok(!!port, "Failed to create completion port, error %u.\n", GetLastError());
@@ -391,8 +389,7 @@ static void test_v1_multiple_requests(void)
ovl2.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
ret = HttpCreateHttpHandle(&queue, 0);
- todo_wine ok(!ret, "Got error %u.\n", ret);
- if (ret) return;
+ ok(!ret, "Got error %u.\n", ret);
ret = HttpAddUrl(queue, localhost_urlW, NULL);
ok(!ret, "Got error %u.\n", ret);
@@ -493,8 +490,7 @@ static void test_v1_short_buffer(void)
ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
ret = HttpCreateHttpHandle(&queue, 0);
- todo_wine ok(!ret, "Got error %u.\n", ret);
- if (ret) return;
+ ok(!ret, "Got error %u.\n", ret);
ret = HttpAddUrl(queue, localhost_urlW, NULL);
ok(!ret, "Got error %u.\n", ret);
@@ -569,8 +565,7 @@ static void test_v1_entity_body(void)
req_body[i] = i / 111;
ret = HttpCreateHttpHandle(&queue, 0);
- todo_wine ok(!ret, "Got error %u.\n", ret);
- if (ret) return;
+ ok(!ret, "Got error %u.\n", ret);
ret = HttpAddUrl(queue, localhost_urlW, NULL);
ok(!ret, "Got error %u.\n", ret);
@@ -716,8 +711,7 @@ static void test_v1_bad_request(void)
SOCKET s;
ret = HttpCreateHttpHandle(&queue, 0);
- todo_wine ok(!ret, "Got error %u.\n", ret);
- if (ret) return;
+ ok(!ret, "Got error %u.\n", ret);
ret = HttpAddUrl(queue, localhost_urlW, NULL);
ok(!ret, "Got error %u.\n", ret);
@@ -774,8 +768,7 @@ static void test_v1_cooked_url(void)
"\r\n";
ret = HttpCreateHttpHandle(&queue, 0);
- todo_wine ok(!ret, "Got error %u.\n", ret);
- if (ret) return;
+ ok(!ret, "Got error %u.\n", ret);
ret = HttpAddUrl(queue, localhost_urlW, NULL);
ok(!ret, "Got error %u.\n", ret);
@@ -849,8 +842,7 @@ static void test_v1_unknown_tokens(void)
"\r\n";
ret = HttpCreateHttpHandle(&queue, 0);
- todo_wine ok(!ret, "Got error %u.\n", ret);
- if (ret) return;
+ ok(!ret, "Got error %u.\n", ret);
ret = HttpAddUrl(queue, localhost_urlW, NULL);
ok(!ret, "Got error %u.\n", ret);
More information about the wine-cvs
mailing list