From akhaldi@svn.reactos.org Sat Mar 5 10:55:01 2016 From: akhaldi@svn.reactos.org To: ros-diffs@reactos.org Subject: [ros-diffs] [akhaldi] 70947: [WINHTTP_WINETEST] Sync with Wine Staging 1.9.4. CORE-10912 Date: Sat, 05 Mar 2016 10:55:00 +0000 Message-ID: <167036579835.185962.17443086528006845376.generated@iserv.reactos.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1281766232553303561==" --===============1281766232553303561== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Author: akhaldi Date: Sat Mar 5 10:55:00 2016 New Revision: 70947 URL: http://svn.reactos.org/svn/reactos?rev=3D70947&view=3Drev Log: [WINHTTP_WINETEST] Sync with Wine Staging 1.9.4. CORE-10912 Modified: trunk/rostests/winetests/winhttp/winhttp.c Modified: trunk/rostests/winetests/winhttp/winhttp.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/winh= ttp.c?rev=3D70947&r1=3D70946&r2=3D70947&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] (original) +++ trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] Sat Mar 5 10:55:= 00 2016 @@ -34,15 +34,19 @@ #include #include #include +#include //#include "initguid.h" #include #include =20 #include =20 +DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); + static const WCHAR test_useragent[] =3D {'W','i','n','e',' ','R','e','g','r','e','s','s','i','o','n',' ','T','e'= ,'s','t',0}; static const WCHAR test_winehq[] =3D {'t','e','s','t','.','w','i','n','e','h= ','q','.','o','r','g',0}; +static const WCHAR test_winehq_https[] =3D {'h','t','t','p','s',':','/','/',= 't','e','s','t','.','w','i','n','e','h','q','.','o','r','g',':','4','4','3',0= }; static const WCHAR localhostW[] =3D {'l','o','c','a','l','h','o','s','t',0}; =20 static BOOL proxy_active(void) @@ -975,8 +979,9 @@ =20 static void test_secure_connection(void) { + static const char data_start[] =3D " 2014, "available_size =3D %u\n", available_size); + status =3D 0xdeadbeef; size =3D sizeof(status); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUE= RY_FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed unexpectedly %u\n", GetLastError()); - ok(status =3D=3D 200, "request failed unexpectedly %u\n", status); + ok(status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", sta= tus); =20 size =3D 0; ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, N= ULL, &size, NULL); @@ -1073,8 +1083,11 @@ ok(ret =3D=3D TRUE, "WinHttpReadData failed: %u.\n", GetLastError()); if (!size) break; read_size +=3D size; + + if (read_size <=3D 32) + ok(!memcmp(buffer, data_start, sizeof(data_start)-1), "not expec= ted: %.32s\n", buffer); } - ok(read_size > 2014, "read_size =3D %u\n", read_size); + ok(read_size >=3D available_size, "read_size =3D %u, available_size =3D = %u\n", read_size, available_size); =20 cleanup: WinHttpCloseHandle(req); @@ -1120,7 +1133,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUE= RY_FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed unexpectedly %u\n", GetLastError()); - ok(status =3D=3D 200, "request failed unexpectedly %u\n", status); + ok(status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", sta= tus); =20 WinHttpCloseHandle(req); =20 @@ -1156,7 +1169,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUE= RY_FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed unexpectedly %u\n", GetLastError()); - ok(status =3D=3D 200, "request failed unexpectedly %u\n", status); + ok(status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", sta= tus); =20 done: WinHttpCloseHandle(req); @@ -2000,18 +2013,25 @@ "Server: winetest\r\n" "Connection: close\r\n" "WWW-Authenticate: Basic realm=3D\"placebo\"\r\n" +"Content-Length: 12\r\n" +"Content-Type: text/plain\r\n" "\r\n"; =20 static const char okauthmsg[] =3D "HTTP/1.1 200 OK\r\n" "Server: winetest\r\n" "Connection: close\r\n" +"Content-Length: 11\r\n" +"Content-Type: text/plain\r\n" "\r\n"; =20 static const char headmsg[] =3D "HTTP/1.1 200 OK\r\n" "Content-Length: 100\r\n" "\r\n"; + +static const char unauthorized[] =3D "Unauthorized"; +static const char hello_world[] =3D "Hello World"; =20 struct server_info { @@ -2074,9 +2094,16 @@ if (strstr(buffer, "/auth")) { if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q=3D")) + { send(c, okauthmsg, sizeof okauthmsg - 1, 0); + send(c, hello_world, sizeof hello_world - 1, 0); + } else + { send(c, noauthmsg, sizeof noauthmsg - 1, 0); + send(c, unauthorized, sizeof unauthorized - 1, 0); + } + continue; } if (strstr(buffer, "/big")) { @@ -2171,7 +2198,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY= _FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed to query status code %u\n", GetLastError()); - ok(status =3D=3D 200, "request failed unexpectedly %u\n", status); + ok(status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", sta= tus); =20 supported =3D first =3D target =3D 0xdeadbeef; SetLastError(0xdeadbeef); @@ -2218,6 +2245,7 @@ static WCHAR pass2W[] =3D {'p','w','d','2',0}; HINTERNET ses, con, req; DWORD status, size, error, supported, first, target; + char buffer[32]; BOOL ret; =20 ses =3D WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, = NULL, 0); @@ -2288,7 +2316,17 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY= _FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed to query status code %u\n", GetLastError()); - ok(status =3D=3D 401, "request failed unexpectedly %u\n", status); + ok(status =3D=3D HTTP_STATUS_DENIED, "request failed unexpectedly %u\n",= status); + + size =3D 0; + ret =3D WinHttpReadData(req, buffer, sizeof(buffer), &size); + error =3D GetLastError(); + ok(ret || broken(error =3D=3D ERROR_WINHTTP_SHUTDOWN || error =3D=3D ERR= OR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError()); + if (ret) + { + ok(size =3D=3D 12, "expected 12, got %u\n", size); + ok(!memcmp(buffer, unauthorized, 12), "got %s\n", buffer); + } =20 supported =3D first =3D target =3D 0xdeadbeef; SetLastError(0xdeadbeef); @@ -2349,7 +2387,17 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY= _FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed to query status code %u\n", GetLastError()); - ok(status =3D=3D 200, "request failed unexpectedly %u\n", status); + ok(status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", sta= tus); + + size =3D 0; + ret =3D WinHttpReadData(req, buffer, sizeof(buffer), &size); + error =3D GetLastError(); + ok(ret || broken(error =3D=3D ERROR_WINHTTP_SHUTDOWN || error =3D=3D ERR= OR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError()); + if (ret) + { + ok(size =3D=3D 11, "expected 11, got %u\n", size); + ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer); + } =20 WinHttpCloseHandle(req); WinHttpCloseHandle(con); @@ -2385,7 +2433,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY= _FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed to query status code %u\n", GetLastError()); - ok(status =3D=3D 200, "request failed unexpectedly %u\n", status); + ok(status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", sta= tus); =20 WinHttpCloseHandle(req); WinHttpCloseHandle(con); @@ -2403,7 +2451,7 @@ ret =3D WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(u= serW)); ok(ret, "failed to set username %u\n", GetLastError()); =20 - ret =3D WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, pass2W, lstrlenW(= passW)); + ret =3D WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, passW, lstrlenW(p= assW)); ok(ret, "failed to set password %u\n", GetLastError()); =20 ret =3D WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_A= UTH_SCHEME_BASIC, userW, pass2W, NULL); @@ -2419,7 +2467,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY= _FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed to query status code %u\n", GetLastError()); - ok(status =3D=3D 401, "request failed unexpectedly %u\n", status); + ok(status =3D=3D HTTP_STATUS_DENIED, "request failed unexpectedly %u\n",= status); =20 WinHttpCloseHandle(req); WinHttpCloseHandle(con); @@ -2501,7 +2549,7 @@ ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUE= RY_FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "expected success\n"); - ok(status =3D=3D 204, "expected status 204, got %d\n", status); + ok(status =3D=3D HTTP_STATUS_NO_CONTENT, "expected status 204, got %d\n"= , status); =20 SetLastError(0xdeadbeef); size =3D sizeof(status); @@ -2575,14 +2623,14 @@ ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUE= RY_FLAG_NUMBER, NULL, &status, &size, NULL); ok(ret, "failed to get status code %u\n", GetLastError()); - ok(status =3D=3D 200, "got %u\n", status); + ok(status =3D=3D HTTP_STATUS_OK, "got %u\n", status); =20 len =3D 0xdeadbeef; size =3D sizeof(len); ret =3D WinHttpQueryHeaders(req, WINHTTP_QUERY_CONTENT_LENGTH | WINHTTP_= QUERY_FLAG_NUMBER, NULL, &len, &size, 0); ok(ret, "failed to get content-length header %u\n", GetLastError()); - ok(len =3D=3D 100, "got %u\n", len); + ok(len =3D=3D HTTP_STATUS_CONTINUE, "got %u\n", len); =20 count =3D 0xdeadbeef; ret =3D WinHttpQueryDataAvailable(req, &count); @@ -2778,7 +2826,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUER= Y_FLAG_NUMBER, NULL, &status, &size, NULL ); ok( ret, "failed to query status code %u\n", GetLastError() ); - ok( status =3D=3D 200, "request failed unexpectedly %u\n", status ); + ok( status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", st= atus ); =20 WinHttpCloseHandle( req ); =20 @@ -2795,7 +2843,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUER= Y_FLAG_NUMBER, NULL, &status, &size, NULL ); ok( ret, "failed to query status code %u\n", GetLastError() ); - ok( status =3D=3D 200, "request failed unexpectedly %u\n", status ); + ok( status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", st= atus ); =20 WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); @@ -2816,7 +2864,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUER= Y_FLAG_NUMBER, NULL, &status, &size, NULL ); ok( ret, "failed to query status code %u\n", GetLastError() ); - ok( status =3D=3D 200, "request failed unexpectedly %u\n", status ); + ok( status =3D=3D HTTP_STATUS_OK, "request failed unexpectedly %u\n", st= atus ); =20 WinHttpCloseHandle( req ); =20 @@ -2833,7 +2881,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUER= Y_FLAG_NUMBER, NULL, &status, &size, NULL ); ok( ret, "failed to query status code %u\n", GetLastError() ); - ok( status =3D=3D 200 || broken(status =3D=3D 400), "request failed unex= pectedly %u\n", status ); + ok( status =3D=3D HTTP_STATUS_OK || broken(status =3D=3D HTTP_STATUS_BAD= _REQUEST), "request failed unexpectedly %u\n", status ); =20 WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); @@ -2858,7 +2906,7 @@ size =3D sizeof(status); ret =3D WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUER= Y_FLAG_NUMBER, NULL, &status, &size, NULL ); ok( ret, "failed to query status code %u\n", GetLastError() ); - ok( status =3D=3D 400, "request failed unexpectedly %u\n", status ); + ok( status =3D=3D HTTP_STATUS_BAD_REQUEST, "request failed unexpectedly = %u\n", status ); =20 WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); @@ -2908,7 +2956,7 @@ memset( &info, 0, sizeof(info) ); ret =3D WinHttpQueryOption( req, WINHTTP_OPTION_CONNECTION_INFO, &info, = &size ); ok( ret, "failed to retrieve connection info %u\n", GetLastError() ); - ok( info.cbSize =3D=3D sizeof(info), "wrong size %u\n", info.cbSize ); + ok( info.cbSize =3D=3D sizeof(info) || info.cbSize =3D=3D sizeof(info) -= sizeof(info.cbSize) /* Win7 */, "wrong size %u\n", info.cbSize ); =20 ret =3D WinHttpReceiveResponse( req, NULL ); ok( ret, "failed to receive response %u\n", GetLastError() ); @@ -2917,7 +2965,7 @@ memset( &info, 0, sizeof(info) ); ret =3D WinHttpQueryOption( req, WINHTTP_OPTION_CONNECTION_INFO, &info, = &size ); ok( ret, "failed to retrieve connection info %u\n", GetLastError() ); - ok( info.cbSize =3D=3D sizeof(info), "wrong size %u\n", info.cbSize ); + ok( info.cbSize =3D=3D sizeof(info) || info.cbSize =3D=3D sizeof(info) -= sizeof(info.cbSize) /* Win7 */, "wrong size %u\n", info.cbSize ); =20 WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); @@ -3045,8 +3093,9 @@ WinHttpCloseHandle(ses); } =20 -static void test_IWinHttpRequest(void) +static void test_IWinHttpRequest(int port) { + static const WCHAR data_start[] =3D {'<','!','D','O','C','T','Y','P','E'= ,' ','h','t','m','l',' ','P','U','B','L','I','C'}; static const WCHAR usernameW[] =3D {'u','s','e','r','n','a','m','e',0}; static const WCHAR passwordW[] =3D {'p','a','s','s','w','o','r','d',0}; static const WCHAR url1W[] =3D {'h','t','t','p',':','/','/','t','e','s',= 't','.','w','i','n','e','h','q','.','o','r','g',0}; @@ -3062,6 +3111,7 @@ static const WCHAR dateW[] =3D {'D','a','t','e',0}; static const WCHAR test_dataW[] =3D {'t','e','s','t','d','a','t','a',128= ,0}; static const WCHAR utf8W[] =3D {'u','t','f','-','8',0}; + static const WCHAR unauthW[] =3D {'U','n','a','u','t','h','o','r','i','z= ','e','d',0}; HRESULT hr; IWinHttpRequest *req; BSTR method, url, username, password, response =3D NULL, status_text =3D= NULL, headers =3D NULL; @@ -3074,6 +3124,7 @@ IStream *stream, *stream2; LARGE_INTEGER pos; char buf[128]; + WCHAR bufW[128]; DWORD count; =20 GetSystemTime( &st ); @@ -3354,6 +3405,7 @@ =20 hr =3D IWinHttpRequest_get_ResponseText( req, &response ); ok( hr =3D=3D S_OK, "got %08x\n", hr ); + ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_= dbgstr_wn(response, 32) ); SysFreeString( response ); =20 hr =3D IWinHttpRequest_get_Status( req, NULL ); @@ -3554,6 +3606,66 @@ SysFreeString( today ); VariantClear( &proxy_server ); VariantClear( &bypass_list ); + + hr =3D CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERV= ER, &IID_IWinHttpRequest, (void **)&req ); + ok( hr =3D=3D S_OK, "got %08x\n", hr ); + + url =3D SysAllocString( test_winehq_https ); + method =3D SysAllocString( method3W ); + V_VT( &async ) =3D VT_BOOL; + V_BOOL( &async ) =3D VARIANT_FALSE; + hr =3D IWinHttpRequest_Open( req, method, url, async ); + ok( hr =3D=3D S_OK, "got %08x\n", hr ); + SysFreeString( method ); + SysFreeString( url ); + + hr =3D IWinHttpRequest_Send( req, empty ); + ok( hr =3D=3D S_OK || broken(hr =3D=3D HRESULT_FROM_WIN32( ERROR_WINHTTP= _INVALID_SERVER_RESPONSE )), "got %08x\n", hr ); + if (hr =3D=3D S_OK) + { + hr =3D IWinHttpRequest_get_ResponseText( req, &response ); + ok( hr =3D=3D S_OK, "got %08x\n", hr ); + ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", w= ine_dbgstr_wn(response, 32) ); + SysFreeString( response ); + } + + IWinHttpRequest_Release( req ); + + hr =3D CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERV= ER, &IID_IWinHttpRequest, (void **)&req ); + ok( hr =3D=3D S_OK, "got %08x\n", hr ); + + sprintf( buf, "http://localhost:%d/auth", port ); + MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, sizeof(bufW)/sizeof(bufW[= 0]) ); + url =3D SysAllocString( bufW ); + method =3D SysAllocString( method3W ); + V_VT( &async ) =3D VT_BOOL; + V_BOOL( &async ) =3D VARIANT_FALSE; + hr =3D IWinHttpRequest_Open( req, method, url, async ); + ok( hr =3D=3D S_OK, "got %08x\n", hr ); + SysFreeString( method ); + SysFreeString( url ); + + hr =3D IWinHttpRequest_get_Status( req, &status ); + ok( hr =3D=3D HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND = ), "got %08x\n", hr ); + + V_VT( &data ) =3D VT_BSTR; + V_BSTR( &data ) =3D SysAllocString( test_dataW ); + hr =3D IWinHttpRequest_Send( req, data ); + ok( hr =3D=3D S_OK, "got %08x\n", hr ); + SysFreeString( V_BSTR( &data ) ); + + hr =3D IWinHttpRequest_get_ResponseText( req, &response ); + ok( hr =3D=3D S_OK, "got %08x\n", hr ); + ok( !memcmp( response, unauthW, sizeof(unauthW) ), "got %s\n", wine_dbgs= tr_w(response) ); + SysFreeString( response ); + + status =3D 0xdeadbeef; + hr =3D IWinHttpRequest_get_Status( req, &status ); + ok( hr =3D=3D S_OK, "got %08x\n", hr ); + ok( status =3D=3D HTTP_STATUS_DENIED, "got %d\n", status ); + + IWinHttpRequest_Release( req ); + CoUninitialize(); } =20 @@ -4092,7 +4204,6 @@ test_Timeouts(); test_resolve_timeout(); test_credentials(); - test_IWinHttpRequest(); test_IWinHttpRequest_Invoke(); test_WinHttpDetectAutoProxyConfigUrl(); test_WinHttpGetIEProxyConfigForCurrentUser(); @@ -4110,6 +4221,7 @@ if (ret !=3D WAIT_OBJECT_0) return; =20 + test_IWinHttpRequest(si.port); test_connection_info(si.port); test_basic_request(si.port, NULL, basicW); test_no_headers(si.port); --===============1281766232553303561==--