diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 14d4d1e882..d1becf81a1 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2116,17 +2116,18 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe return ERROR_SUCCESS; case INTERNET_OPTION_URL: { - static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0}; - WCHAR url[INTERNET_MAX_URL_LENGTH]; + WCHAR *url; + DWORD res; TRACE("INTERNET_OPTION_URL\n"); - strcpyW(url, httpW); - strcatW(url, req->server->canon_host_port); - strcatW(url, req->path); + url = compose_request_url(req); + if(!url) + return ERROR_OUTOFMEMORY; - TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url)); - return str_to_buffer(url, buffer, size, unicode); + res = str_to_buffer(url, buffer, size, unicode); + heap_free(url); + return res; } case INTERNET_OPTION_USER_AGENT: return str_to_buffer(req->session->appInfo->agent, buffer, size, unicode); diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 29dd965ac6..f27db62370 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -4720,8 +4720,9 @@ static void test_http_read(int port) static void test_long_url(int port) { char long_path[INTERNET_MAX_PATH_LENGTH*2] = "/echo_request?"; - char buf[sizeof(long_path)*2]; + char buf[sizeof(long_path)*2], url[sizeof(buf)]; test_request_t req; + DWORD size, len; BOOL ret; memset(long_path+strlen(long_path), 'x', sizeof(long_path)-strlen(long_path)); @@ -4735,6 +4736,15 @@ static void test_long_url(int port) receive_simple_request(req.request, buf, sizeof(buf)); ok(strstr(buf, long_path) != NULL, "long pathnot found in %s\n", buf); + sprintf(url, "http://localhost:%u%s", port, long_path); + + size = sizeof(buf); + ret = InternetQueryOptionA(req.request, INTERNET_OPTION_URL, buf, &size); + ok(ret, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError()); + len = strlen(url); + ok(size == len, "size = %u, expected %u\n", size, len); + ok(!strcmp(buf, url), "Wrong URL %s, expected %s\n", buf, url); + close_request(&req); }