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@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-08-28 20:45:29 -05:00 committed by Alexandre Julliard
parent d73fc3e82a
commit efacf6f455
3 changed files with 44 additions and 20 deletions

View File

@ -1,5 +1,6 @@
MODULE = httpapi.dll
IMPORTLIB = httpapi
IMPORTS = advapi32
EXTRADLLFLAGS = -mno-cygwin

View File

@ -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,
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);
return NO_ERROR;
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;
}
/***********************************************************************

View File

@ -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);