Commit 4f51b6c1 authored by Alexander Morozov's avatar Alexander Morozov Committed by Alexandre Julliard

wininet: Add port number to Host HTTP header.

parent ad2f53db
...@@ -1453,14 +1453,20 @@ static DWORD HTTPREQ_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b ...@@ -1453,14 +1453,20 @@ static DWORD HTTPREQ_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b
WCHAR url[INTERNET_MAX_URL_LENGTH]; WCHAR url[INTERNET_MAX_URL_LENGTH];
HTTPHEADERW *host; HTTPHEADERW *host;
DWORD len; DWORD len;
WCHAR *pch;
static const WCHAR formatW[] = {'h','t','t','p',':','/','/','%','s','%','s',0}; static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0};
static const WCHAR hostW[] = {'H','o','s','t',0}; static const WCHAR hostW[] = {'H','o','s','t',0};
TRACE("INTERNET_OPTION_URL\n"); TRACE("INTERNET_OPTION_URL\n");
host = HTTP_GetHeader(req, hostW); host = HTTP_GetHeader(req, hostW);
sprintfW(url, formatW, host->lpszValue, req->lpszPath); strcpyW(url, httpW);
strcatW(url, host->lpszValue);
if (NULL != (pch = strchrW(url + strlenW(httpW), ':')))
*pch = 0;
strcatW(url, req->lpszPath);
TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url)); TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url));
if(unicode) { if(unicode) {
...@@ -1885,9 +1891,11 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, ...@@ -1885,9 +1891,11 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
LPWININETHTTPREQW lpwhr; LPWININETHTTPREQW lpwhr;
LPWSTR lpszCookies; LPWSTR lpszCookies;
LPWSTR lpszUrl = NULL; LPWSTR lpszUrl = NULL;
LPWSTR lpszHostName = NULL;
DWORD nCookieSize; DWORD nCookieSize;
HINTERNET handle = NULL; HINTERNET handle = NULL;
static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0}; static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0};
static const WCHAR szHostForm[] = {'%','s',':','%','u',0};
DWORD len; DWORD len;
LPHTTPHEADERW Host; LPHTTPHEADERW Host;
...@@ -1914,6 +1922,14 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, ...@@ -1914,6 +1922,14 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
lpwhr->lpHttpSession = lpwhs; lpwhr->lpHttpSession = lpwhs;
list_add_head( &lpwhs->hdr.children, &lpwhr->hdr.entry ); list_add_head( &lpwhs->hdr.children, &lpwhr->hdr.entry );
lpszHostName = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) *
(strlenW(lpwhs->lpszHostName) + 7 /* length of ":65535" + 1 */));
if (NULL == lpszHostName)
{
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
goto lend;
}
handle = WININET_AllocHandle( &lpwhr->hdr ); handle = WININET_AllocHandle( &lpwhr->hdr );
if (NULL == handle) if (NULL == handle)
{ {
...@@ -1968,7 +1984,17 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, ...@@ -1968,7 +1984,17 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
else else
lpwhr->lpszVersion = WININET_strdupW(g_szHttp1_1); lpwhr->lpszVersion = WININET_strdupW(g_szHttp1_1);
HTTP_ProcessHeader(lpwhr, szHost, lpwhs->lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ); if (lpwhs->nHostPort != INTERNET_INVALID_PORT_NUMBER &&
lpwhs->nHostPort != INTERNET_DEFAULT_HTTP_PORT &&
lpwhs->nHostPort != INTERNET_DEFAULT_HTTPS_PORT)
{
sprintfW(lpszHostName, szHostForm, lpwhs->lpszHostName, lpwhs->nHostPort);
HTTP_ProcessHeader(lpwhr, szHost, lpszHostName,
HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ);
}
else
HTTP_ProcessHeader(lpwhr, szHost, lpwhs->lpszHostName,
HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ);
if (lpwhs->nServerPort == INTERNET_INVALID_PORT_NUMBER) if (lpwhs->nServerPort == INTERNET_INVALID_PORT_NUMBER)
lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ? lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ?
...@@ -2014,6 +2040,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, ...@@ -2014,6 +2040,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
sizeof(handle)); sizeof(handle));
lend: lend:
HeapFree(GetProcessHeap(), 0, lpszHostName);
if( lpwhr ) if( lpwhr )
WININET_Release( &lpwhr->hdr ); WININET_Release( &lpwhr->hdr );
......
...@@ -1734,7 +1734,6 @@ static void test_connection_header(int port) ...@@ -1734,7 +1734,6 @@ static void test_connection_header(int port)
size = sizeof(status); size = sizeof(status);
ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL);
ok(ret, "HttpQueryInfo failed\n"); ok(ret, "HttpQueryInfo failed\n");
todo_wine
ok(status == 200, "request failed with status %u\n", status); ok(status == 200, "request failed with status %u\n", status);
InternetCloseHandle(req); InternetCloseHandle(req);
...@@ -1749,7 +1748,6 @@ static void test_connection_header(int port) ...@@ -1749,7 +1748,6 @@ static void test_connection_header(int port)
size = sizeof(status); size = sizeof(status);
ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL);
ok(ret, "HttpQueryInfo failed\n"); ok(ret, "HttpQueryInfo failed\n");
todo_wine
ok(status == 200, "request failed with status %u\n", status); ok(status == 200, "request failed with status %u\n", status);
InternetCloseHandle(req); InternetCloseHandle(req);
...@@ -1764,7 +1762,6 @@ static void test_connection_header(int port) ...@@ -1764,7 +1762,6 @@ static void test_connection_header(int port)
size = sizeof(status); size = sizeof(status);
ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL);
ok(ret, "HttpQueryInfo failed\n"); ok(ret, "HttpQueryInfo failed\n");
todo_wine
ok(status == 200, "request failed with status %u\n", status); ok(status == 200, "request failed with status %u\n", status);
InternetCloseHandle(req); InternetCloseHandle(req);
...@@ -1779,7 +1776,6 @@ static void test_connection_header(int port) ...@@ -1779,7 +1776,6 @@ static void test_connection_header(int port)
size = sizeof(status); size = sizeof(status);
ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL); ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL);
ok(ret, "HttpQueryInfo failed\n"); ok(ret, "HttpQueryInfo failed\n");
todo_wine
ok(status == 200, "request failed with status %u\n", status); ok(status == 200, "request failed with status %u\n", status);
InternetCloseHandle(req); InternetCloseHandle(req);
......
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