Alexander Morozov : wininet: Add port number to Host HTTP header.
Alexandre Julliard
julliard at winehq.org
Mon Jul 7 09:19:25 CDT 2008
Module: wine
Branch: master
Commit: 4f51b6c1d8582e57ddc97c23f8ec8bfe91842fe6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4f51b6c1d8582e57ddc97c23f8ec8bfe91842fe6
Author: Alexander Morozov <amorozov at etersoft.ru>
Date: Thu Jul 3 16:34:40 2008 +0400
wininet: Add port number to Host HTTP header.
---
dlls/wininet/http.c | 33 ++++++++++++++++++++++++++++++---
dlls/wininet/tests/http.c | 4 ----
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 8171838..7607721 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -1453,14 +1453,20 @@ static DWORD HTTPREQ_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *b
WCHAR url[INTERNET_MAX_URL_LENGTH];
HTTPHEADERW *host;
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};
TRACE("INTERNET_OPTION_URL\n");
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));
if(unicode) {
@@ -1885,9 +1891,11 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
LPWININETHTTPREQW lpwhr;
LPWSTR lpszCookies;
LPWSTR lpszUrl = NULL;
+ LPWSTR lpszHostName = NULL;
DWORD nCookieSize;
HINTERNET handle = NULL;
static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0};
+ static const WCHAR szHostForm[] = {'%','s',':','%','u',0};
DWORD len;
LPHTTPHEADERW Host;
@@ -1914,6 +1922,14 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
lpwhr->lpHttpSession = lpwhs;
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 );
if (NULL == handle)
{
@@ -1968,7 +1984,17 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
else
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)
lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ?
@@ -2014,6 +2040,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
sizeof(handle));
lend:
+ HeapFree(GetProcessHeap(), 0, lpszHostName);
if( lpwhr )
WININET_Release( &lpwhr->hdr );
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index d6da2ca..272e3e7 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1734,7 +1734,6 @@ static void test_connection_header(int port)
size = sizeof(status);
ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL);
ok(ret, "HttpQueryInfo failed\n");
- todo_wine
ok(status == 200, "request failed with status %u\n", status);
InternetCloseHandle(req);
@@ -1749,7 +1748,6 @@ static void test_connection_header(int port)
size = sizeof(status);
ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL);
ok(ret, "HttpQueryInfo failed\n");
- todo_wine
ok(status == 200, "request failed with status %u\n", status);
InternetCloseHandle(req);
@@ -1764,7 +1762,6 @@ static void test_connection_header(int port)
size = sizeof(status);
ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL);
ok(ret, "HttpQueryInfo failed\n");
- todo_wine
ok(status == 200, "request failed with status %u\n", status);
InternetCloseHandle(req);
@@ -1779,7 +1776,6 @@ static void test_connection_header(int port)
size = sizeof(status);
ret = HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL);
ok(ret, "HttpQueryInfo failed\n");
- todo_wine
ok(status == 200, "request failed with status %u\n", status);
InternetCloseHandle(req);
More information about the wine-cvs
mailing list