[2/2] wininet: if User-Agent is not provided by user, set it to app's name in HttpSendRequest() instead of HttpOpenRequest().

Rok Mandeljc rok.mandeljc at email.si
Sat Apr 12 11:00:56 CDT 2008


---
 dlls/wininet/http.c |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index e2ee9af..41d5763 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -1962,20 +1962,11 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
     if (NULL != hIC->lpszProxy && hIC->lpszProxy[0] != 0)
         HTTP_DealWithProxy( hIC, lpwhs, lpwhr );
 
-    if (hIC->lpszAgent)
-    {
-        WCHAR *agent_header;
-        static const WCHAR user_agent[] = {'U','s','e','r','-','A','g','e','n','t',':',' ','%','s','\r','\n',0 };
-
-        len = strlenW(hIC->lpszAgent) + strlenW(user_agent);
-        agent_header = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
-        sprintfW(agent_header, user_agent, hIC->lpszAgent );
-
-        HTTP_HttpAddRequestHeadersW(lpwhr, agent_header, strlenW(agent_header),
-                               HTTP_ADDREQ_FLAG_ADD);
-        HeapFree(GetProcessHeap(), 0, agent_header);
-    }
-
+    /* 
+     * with native, User-Agent isn't set on the newly created request; if user 
+     * doesn't append one, application's name is added when request is sent.
+     */
+    
     Host = HTTP_GetHeader(lpwhr,szHost);
 
     len = lstrlenW(Host->lpszValue) + strlenW(szUrlForm);
@@ -3195,6 +3186,14 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
                         HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REPLACE);
         }
 
+        /* add application's name as User-Agent if user didn't specify one */
+        if (lpwhr->lpHttpSession->lpAppInfo->lpszAgent)
+        {
+            HTTP_ProcessHeader(lpwhr, szUser_Agent,
+                               lpwhr->lpHttpSession->lpAppInfo->lpszAgent,
+                               HTTP_ADDHDR_FLAG_REQ | HTTP_ADDHDR_FLAG_ADD_IF_NEW);
+        }
+        
         if (lpwhr->lpHttpSession->lpAppInfo->lpszProxy && lpwhr->lpHttpSession->lpAppInfo->lpszProxy[0])
         {
             WCHAR *url = HTTP_BuildProxyRequestUrl(lpwhr);
-- 
1.5.4.1




More information about the wine-patches mailing list