Commit 13a95f16 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Move InternetQueryOption(INTERNET_OPTION_USER_AGENT) to vtbl.

parent a7d06e74
......@@ -3473,7 +3473,7 @@ static DWORD HTTPSESSION_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, voi
}
FIXME("Not implemented option %d\n", option);
return ERROR_INTERNET_INVALID_OPTION;
return ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
}
static const HANDLEHEADERVtbl HTTPSESSIONVtbl = {
......
......@@ -495,6 +495,8 @@ static VOID APPINFO_Destroy(WININETHANDLEHEADER *hdr)
static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
{
LPWININETAPPINFOW ai = (LPWININETAPPINFOW)hdr;
switch(option) {
case INTERNET_OPTION_HANDLE_TYPE:
TRACE("INTERNET_OPTION_HANDLE_TYPE\n");
......@@ -505,6 +507,30 @@ static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b
*size = sizeof(DWORD);
*(DWORD*)buffer = INTERNET_HANDLE_TYPE_INTERNET;
return ERROR_SUCCESS;
case INTERNET_OPTION_USER_AGENT: {
DWORD bufsize;
TRACE("INTERNET_OPTION_USER_AGENT\n");
bufsize = *size;
if (unicode) {
*size = (strlenW(ai->lpszAgent) + 1) * sizeof(WCHAR);
if(!buffer || bufsize < *size)
return ERROR_INSUFFICIENT_BUFFER;
strcpyW(buffer, ai->lpszAgent);
}else {
*size = WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, NULL, 0, NULL, NULL);
if(!buffer || bufsize < *size)
return ERROR_INSUFFICIENT_BUFFER;
WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, buffer, *size, NULL, NULL);
}
return ERROR_SUCCESS;
}
}
FIXME("Not implemented option %d\n", option);
......@@ -1959,43 +1985,6 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d
break;
}
case INTERNET_OPTION_USER_AGENT:
{
DWORD required;
LPWININETAPPINFOW ai = (LPWININETAPPINFOW)lpwhh;
TRACE("INTERNET_OPTION_USER_AGENT\n");
if (!lpwhh || lpwhh->htype != INTERNET_HANDLE_TYPE_INTERNET)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
}
if (bIsUnicode)
{
required = (strlenW(ai->lpszAgent) + 1) * sizeof(WCHAR);
if (*lpdwBufferLength < required)
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else if (lpBuffer)
{
strcpyW(lpBuffer, ai->lpszAgent);
bSuccess = TRUE;
}
}
else
{
required = WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, NULL, 0, NULL, NULL);
if (*lpdwBufferLength < required)
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else if (lpBuffer)
{
WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, lpBuffer, required, NULL, NULL);
bSuccess = TRUE;
}
}
*lpdwBufferLength = required;
break;
}
case INTERNET_OPTION_HTTP_VERSION:
{
if (*lpdwBufferLength < sizeof(HTTP_VERSION_INFO))
......@@ -2230,6 +2219,7 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d
SetLastError(res);
}else {
FIXME("Stub! %d\n", dwOption);
SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
break;
}
}
......
......@@ -161,7 +161,7 @@ static void test_InternetQueryOptionA(void)
err=GetLastError();
ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
ok(retval == 0,"Got wrong return value %d\n",retval);
todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
SetLastError(0xdeadbeef);
len=strlen(useragent)+1;
......@@ -221,7 +221,7 @@ static void test_InternetQueryOptionA(void)
err=GetLastError();
todo_wine ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
ok(retval == 0,"Got wrong return value %d\n",retval);
todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
InternetCloseHandle(hinet);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment