Module: wine Branch: master Commit: 61e28c01c60cfe27f13a957ef940c36ef827c9b3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=61e28c01c60cfe27f13a957ef9...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Jun 26 15:36:35 2017 +0200
wininet: Moved INTERNET_STATUS_REDIRECT notification to HTTP_HandleRedirect.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wininet/http.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 17a1919..e0bc55d 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -4039,27 +4039,33 @@ static WCHAR *get_redirect_url(http_request_t *request) /*********************************************************************** * HTTP_HandleRedirect (internal) */ -static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) +static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url) { + URL_COMPONENTSW urlComponents = { sizeof(urlComponents) }; http_session_t *session = request->session; - WCHAR *path; + size_t url_len = strlenW(url);
- if(lpszUrl[0]=='/') + if(url[0] == '/') { /* if it's an absolute path, keep the same session info */ - path = heap_strdupW(lpszUrl); + urlComponents.lpszUrlPath = url; + urlComponents.dwUrlPathLength = url_len; } else { - URL_COMPONENTSW urlComponents = { sizeof(urlComponents) }; - BOOL custom_port = FALSE; - substr_t host; - urlComponents.dwHostNameLength = 1; urlComponents.dwUserNameLength = 1; urlComponents.dwUrlPathLength = 1; - if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents)) + if(!InternetCrackUrlW(url, url_len, 0, &urlComponents)) return INTERNET_GetLastError(); + } + + INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, + url, (url_len + 1) * sizeof(WCHAR)); + + if(urlComponents.dwHostNameLength) { + BOOL custom_port = FALSE; + substr_t host;
if(urlComponents.nScheme == INTERNET_SCHEME_HTTP) { if(request->hdr.dwFlags & INTERNET_FLAG_SECURE) { @@ -4106,23 +4112,25 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) HTTP_ProcessHeader(request, hostW, request->server->host_port, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); else HTTP_ProcessHeader(request, hostW, request->server->name, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); - - path = heap_strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength); } + heap_free(request->path); request->path = NULL; - if (*path) + if(urlComponents.dwUrlPathLength) { DWORD needed = 1; HRESULT rc; WCHAR dummy = 0; + WCHAR *path;
+ path = heap_strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength); rc = UrlEscapeW(path, &dummy, &needed, URL_ESCAPE_SPACES_ONLY); if (rc != E_POINTER) ERR("Unable to escape string!(%s) (%d)\n",debugstr_w(path),rc); request->path = heap_alloc(needed*sizeof(WCHAR)); rc = UrlEscapeW(path, request->path, &needed, URL_ESCAPE_SPACES_ONLY); + heap_free(path); if (rc != S_OK) { ERR("Unable to escape string!(%s) (%d)\n",debugstr_w(path),rc); @@ -4130,8 +4138,6 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) } }
- heap_free(path); - /* Remove custom content-type/length headers on redirects. */ remove_header(request, szContent_Type, TRUE); remove_header(request, szContent_Length, TRUE); @@ -5040,8 +5046,6 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, request->verb = heap_strdupW(szGET); } http_release_netconn(request, drain_content(request, FALSE)); - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, - new_url, (strlenW(new_url) + 1) * sizeof(WCHAR)); res = HTTP_HandleRedirect(request, new_url); heap_free(new_url); if (res == ERROR_SUCCESS) { @@ -5238,8 +5242,6 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_ request->verb = heap_strdupW(szGET); } http_release_netconn(request, drain_content(request, FALSE)); - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, - new_url, (strlenW(new_url) + 1) * sizeof(WCHAR)); res = HTTP_HandleRedirect(request, new_url); heap_free(new_url); if (res == ERROR_SUCCESS)