wininet: Use processed string from server_t for constructing proxy path.

This commit is contained in:
Jacek Caban 2012-11-19 11:47:50 +01:00 committed by Alexandre Julliard
parent 3cf2838a93
commit 5fb49243af
1 changed files with 15 additions and 31 deletions

View File

@ -1679,41 +1679,25 @@ static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthIn
return TRUE; return TRUE;
} }
static WCHAR *HTTP_BuildProxyRequestUrl(http_request_t *req) static WCHAR *build_proxy_path_url(http_request_t *req)
{ {
static const WCHAR slash[] = { '/',0 }; DWORD size, len;
static const WCHAR format[] = { 'h','t','t','p',':','/','/','%','s',':','%','u',0 }; WCHAR *url;
static const WCHAR formatSSL[] = { 'h','t','t','p','s',':','/','/','%','s',':','%','u',0 };
http_session_t *session = req->session;
WCHAR new_location[INTERNET_MAX_URL_LENGTH], *url;
DWORD size;
size = sizeof(new_location); len = strlenW(req->server->scheme_host_port);
if (HTTP_HttpQueryInfoW(req, HTTP_QUERY_LOCATION, new_location, &size, NULL) == ERROR_SUCCESS) size = len + strlenW(req->path) + 1;
{ if(*req->path != '/')
URL_COMPONENTSW UrlComponents; size++;
url = heap_alloc(size * sizeof(WCHAR));
if(!url)
return NULL;
if (!(url = heap_alloc(size + sizeof(WCHAR)))) return NULL; memcpy(url, req->server->scheme_host_port, len*sizeof(WCHAR));
strcpyW( url, new_location ); if(*req->path != '/')
url[len++] = '/';
ZeroMemory(&UrlComponents,sizeof(URL_COMPONENTSW)); strcpyW(url+len, req->path);
if(InternetCrackUrlW(url, 0, 0, &UrlComponents)) goto done;
heap_free(url);
}
size = 16; /* "https://" + sizeof(port#) + ":/\0" */
size += strlenW( session->hostName ) + strlenW( req->path );
if (!(url = heap_alloc(size * sizeof(WCHAR)))) return NULL;
if (req->hdr.dwFlags & INTERNET_FLAG_SECURE)
sprintfW( url, formatSSL, session->hostName, session->hostPort );
else
sprintfW( url, format, session->hostName, session->hostPort );
if (req->path[0] != '/') strcatW( url, slash );
strcatW( url, req->path );
done:
TRACE("url=%s\n", debugstr_w(url)); TRACE("url=%s\n", debugstr_w(url));
return url; return url;
} }
@ -4856,7 +4840,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
if (request->session->appInfo->proxy && request->session->appInfo->proxy[0]) if (request->session->appInfo->proxy && request->session->appInfo->proxy[0])
{ {
WCHAR *url = HTTP_BuildProxyRequestUrl(request); WCHAR *url = build_proxy_path_url(request);
requestString = HTTP_BuildHeaderRequestString(request, request->verb, url, request->version); requestString = HTTP_BuildHeaderRequestString(request, request->verb, url, request->version);
heap_free(url); heap_free(url);
} }