wininet: Get the string for the scheme if specified only by the

INTERNET_SCHEME enumeration in InternetCreateUrlW.
oldstable
Robert Shearman 2006-03-09 15:15:45 +00:00 committed by Alexandre Julliard
parent 01219c65aa
commit 02839948d2
2 changed files with 45 additions and 1 deletions

View File

@ -3712,6 +3712,17 @@ static BOOL url_uses_default_port(LPURL_COMPONENTSW lpUrlComponents)
return FALSE;
}
static LPCWSTR INTERNET_GetSchemeString(INTERNET_SCHEME scheme)
{
int index;
if (scheme < INTERNET_SCHEME_FIRST)
return NULL;
index = scheme - INTERNET_SCHEME_FIRST;
if (index >= sizeof(url_schemes)/sizeof(url_schemes[0]))
return NULL;
return (LPCWSTR)&url_schemes[index];
}
/* we can calculate using ansi strings because we're just
* calculating string length, not size
*/
@ -3720,7 +3731,15 @@ static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents,
{
*lpdwUrlLength = 0;
*lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, Scheme);
if (lpUrlComponents->lpszScheme)
*lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, Scheme);
else
{
LPCWSTR scheme = INTERNET_GetSchemeString(lpUrlComponents->nScheme);
TRACE("got scheme %s\n", debugstr_w(scheme));
*lpdwUrlLength += strlenW(scheme);
}
*lpdwUrlLength += strlen("://");
if (lpUrlComponents->lpszUserName)
@ -3922,6 +3941,13 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
memcpy(lpszUrl, lpUrlComponents->lpszScheme, dwLen * sizeof(WCHAR));
lpszUrl += dwLen;
}
else
{
LPCWSTR scheme = INTERNET_GetSchemeString(lpUrlComponents->nScheme);
dwLen = strlenW(scheme);
memcpy(lpszUrl, scheme, dwLen * sizeof(WCHAR));
lpszUrl += dwLen;
}
memcpy(lpszUrl, colonSlashW, sizeof(colonSlashW));
lpszUrl += sizeof(colonSlashW)/sizeof(colonSlashW[0]);

View File

@ -47,6 +47,7 @@
#define CREATE_URL6 "nhttp://username:password@www.winehq.org:80/site/about"
#define CREATE_URL7 "http://username:password@www.winehq.org:42/site/about"
#define CREATE_URL8 "https://username:password@www.winehq.org/site/about"
#define CREATE_URL9 "about:blank"
static HANDLE hCompleteEvent;
@ -1102,6 +1103,23 @@ static void InternetCreateUrlA_test(void)
ok(!strcmp(szUrl, CREATE_URL8), "Expected %s, got %s\n", CREATE_URL8, szUrl);
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
urlComp.dwStructSize = sizeof(URL_COMPONENTS);
urlComp.lpszScheme = "about";
urlComp.dwSchemeLength = 5;
urlComp.lpszUrlPath = "blank";
urlComp.dwUrlPathLength = 5;
len = strlen(CREATE_URL9);
szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
todo_wine {
ok(ret, "Expected success\n");
ok(len == strlen(CREATE_URL9), "Expected len %d, got %ld\n", strlen(CREATE_URL9), len);
ok(!strcmp(szUrl, CREATE_URL9), "Expected %s, got %s\n", CREATE_URL9, szUrl);
}
HeapFree(GetProcessHeap(), 0, szUrl);
}
static void HttpSendRequestEx_test(void)