WININET: convert the HTTP functions to Unicode

Mike McCormack mike at codeweavers.com
Sun Mar 28 00:24:55 CST 2004


ChangeLog:
* convert the wininet HTTP functions to Unicode
-------------- next part --------------
? dlls/wininet/wininet.spec.c
? dlls/wininet/tests/wininet_test.exe.spec.c
Index: include/wininet.h
===================================================================
RCS file: /home/wine/wine/include/wininet.h,v
retrieving revision 1.18
diff -u -r1.18 wininet.h
--- include/wininet.h	8 Oct 2003 02:57:07 -0000	1.18
+++ include/wininet.h	28 Mar 2004 05:32:59 -0000
@@ -1142,11 +1142,11 @@
 #define HttpQueryInfo  WINELIB_NAME_AW(HttpQueryInfo)
 
 BOOLAPI InternetSetCookieA(LPCSTR ,LPCSTR ,LPCSTR);
-BOOLAPI InternetSetCookieW(LPCSTR ,LPCWSTR ,LPCWSTR);
+BOOLAPI InternetSetCookieW(LPCWSTR ,LPCWSTR ,LPCWSTR);
 #define InternetSetCookie  WINELIB_NAME_AW(InternetSetCookie)
 
 BOOLAPI InternetGetCookieA(LPCSTR ,LPCSTR ,LPSTR ,LPDWORD);
-BOOLAPI InternetGetCookieW(LPCSTR ,LPCWSTR ,LPWSTR ,LPDWORD);
+BOOLAPI InternetGetCookieW(LPCWSTR ,LPCWSTR ,LPWSTR ,LPDWORD);
 #define InternetGetCookie  WINELIB_NAME_AW(InternetGetCookie)
 
 INTERNETAPI DWORD WINAPI InternetAttemptConnect(DWORD);
Index: dlls/wininet/cookie.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/cookie.c,v
retrieving revision 1.3
diff -u -r1.3 cookie.c
--- dlls/wininet/cookie.c	5 Sep 2003 23:08:28 -0000	1.3
+++ dlls/wininet/cookie.c	28 Mar 2004 05:32:59 -0000
@@ -404,11 +404,11 @@
  *    FALSE on failure
  *
  */
-BOOL WINAPI InternetGetCookieW(LPCSTR lpszUrl, LPCWSTR lpszCookieName,
+BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
     LPWSTR lpCookieData, LPDWORD lpdwSize)
 {
     FIXME("STUB\n");
-    TRACE("(%s,%s,%p)\n", debugstr_a(lpszUrl), debugstr_w(lpszCookieName),
+    TRACE("(%s,%s,%p)\n", debugstr_w(lpszUrl), debugstr_w(lpszCookieName),
         lpCookieData);
     return FALSE;
 }
@@ -483,11 +483,11 @@
  *    FALSE on failure
  *
  */
-BOOL WINAPI InternetSetCookieW(LPCSTR lpszUrl, LPCWSTR lpszCookieName,
+BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
     LPCWSTR lpCookieData)
 {
     FIXME("STUB\n");
-    TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl),
+    TRACE("(%s,%s,%s)\n", debugstr_w(lpszUrl),
         debugstr_w(lpszCookieName), debugstr_w(lpCookieData));
     return FALSE;
 }
Index: dlls/wininet/dialogs.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/dialogs.c,v
retrieving revision 1.3
diff -u -r1.3 dialogs.c
--- dlls/wininet/dialogs.c	25 Mar 2004 05:29:47 -0000	1.3
+++ dlls/wininet/dialogs.c	28 Mar 2004 05:32:59 -0000
@@ -58,15 +58,15 @@
  */
 static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz )
 {
-    LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hRequest;
-    LPWININETHTTPSESSIONA lpwhs = NULL;
+    LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hRequest;
+    LPWININETHTTPSESSIONW lpwhs = NULL;
     LPWININETAPPINFOW hIC = NULL;
     LPWSTR p;
 
     if (NULL == lpwhr)
 	return FALSE;
 
-    lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
+    lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
     if (NULL == lpwhs)
 	return FALSE;
 
@@ -194,12 +194,12 @@
 static BOOL WININET_SetProxyAuthorization( HINTERNET hRequest,
                                          LPWSTR username, LPWSTR password )
 {
-    LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hRequest;
-    LPWININETHTTPSESSIONA lpwhs;
+    LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hRequest;
+    LPWININETHTTPSESSIONW lpwhs;
     LPWININETAPPINFOW hIC;
     LPWSTR p;
 
-    lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
+    lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
     if (NULL == lpwhs ||  lpwhs->hdr.htype != WH_HHTTPSESSION)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
@@ -272,7 +272,7 @@
     case WM_COMMAND:
         if( wParam == IDOK )
         {
-            LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) params->hRequest;
+            LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) params->hRequest;
             WCHAR username[0x20], password[0x20];
 
             username[0] = 0;
@@ -320,7 +320,7 @@
 
     TRACE("%p\n", hRequest );
 
-    sz = sizeof(szStatus) / sizeof(WCHAR);
+    sz = sizeof szStatus;
     index = 0;
     if( !HttpQueryInfoW( hRequest, HTTP_QUERY_STATUS_CODE,
                     szStatus, &sz, &index))
Index: dlls/wininet/ftp.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/ftp.c,v
retrieving revision 1.39
diff -u -r1.39 ftp.c
--- dlls/wininet/ftp.c	25 Mar 2004 05:29:47 -0000	1.39
+++ dlls/wininet/ftp.c	28 Mar 2004 05:32:59 -0000
@@ -144,6 +144,15 @@
     return ret;
 }
 
+inline static LPSTR FTP_strdup_WtoA( LPCWSTR str )
+{
+    int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
+    LPSTR ret = HeapAlloc( GetProcessHeap(), 0, len );
+    if (ret)
+        WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL);
+    return ret;
+}
+
 /***********************************************************************
  *           FtpPutFileA (WININET.@)
  *
@@ -1475,9 +1484,9 @@
  *
  */
 
-HINTERNET FTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
-	INTERNET_PORT nServerPort, LPCSTR lpszUserName,
-	LPCSTR lpszPassword, DWORD dwFlags, DWORD dwContext)
+HINTERNET FTP_Connect(HINTERNET hInternet, LPCWSTR lpszServerName,
+	INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
+	LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext)
 {
     struct sockaddr_in socketAddr;
     struct hostent *phe = NULL;
@@ -1488,8 +1497,8 @@
     HINTERNET handle = NULL;
 
     TRACE("0x%08lx  Server(%s) Port(%d) User(%s) Paswd(%s)\n",
-	    (ULONG) hInternet, lpszServerName,
-	    nServerPort, lpszUserName, lpszPassword);
+	    (ULONG) hInternet, debugstr_w(lpszServerName),
+	    nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword));
 
     hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
     if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
@@ -1506,7 +1515,7 @@
 
     if (hIC->lpfnStatusCB)
         hIC->lpfnStatusCB(hInternet, dwContext, INTERNET_STATUS_RESOLVING_NAME,
-            (LPSTR) lpszServerName, strlen(lpszServerName));
+            (LPWSTR) lpszServerName, strlenW(lpszServerName));
 
     if (!GetAddress(lpszServerName, nServerPort, &phe, &socketAddr))
     {
@@ -1516,7 +1525,7 @@
 
     if (hIC->lpfnStatusCB)
         hIC->lpfnStatusCB(hInternet, dwContext, INTERNET_STATUS_NAME_RESOLVED,
-            (LPSTR) lpszServerName, strlen(lpszServerName));
+            (LPWSTR) lpszServerName, strlenW(lpszServerName));
 
     nsocket = socket(AF_INET,SOCK_STREAM,0);
     if (nsocket == -1)
@@ -1558,7 +1567,7 @@
         lpwfs->hdr.htype = WH_HFTPSESSION;
         lpwfs->hdr.dwFlags = dwFlags;
         lpwfs->hdr.dwContext = dwContext;
-        lpwfs->hdr.lpwhparent = &hIC->hdr;
+        lpwfs->hdr.lpwhparent = (LPWININETHANDLEHEADER)hInternet;
         lpwfs->sndSocket = nsocket;
 	lpwfs->download_in_progress = NULL;
 	sock_namelen = sizeof(lpwfs->socketAddress);
@@ -1572,8 +1581,8 @@
         }
         else
         {
-            lpwfs->lpszUserName = FTP_strdup(lpszUserName);
-            lpwfs->lpszPassword = FTP_strdup(lpszPassword);
+            lpwfs->lpszUserName = FTP_strdup_WtoA(lpszUserName);
+            lpwfs->lpszPassword = FTP_strdup_WtoA(lpszPassword);
         }
 
         if (FTP_ConnectToHost(lpwfs))
@@ -2543,7 +2552,7 @@
             if( handle )
             {
                 lpwfn->hdr.htype = WH_HFINDNEXT;
-                lpwfn->hdr.lpwhparent = &lpwfs->hdr;
+                lpwfn->hdr.lpwhparent = (LPWININETHANDLEHEADER)lpwfs;
 	        lpwfn->hdr.dwContext = dwContext;
                 lpwfn->index = 1; /* Next index is 1 since we return index 0 */
                 lpwfn->size = dwSize;
Index: dlls/wininet/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/http.c,v
retrieving revision 1.53
diff -u -r1.53 http.c
--- dlls/wininet/http.c	25 Mar 2004 05:29:47 -0000	1.53
+++ dlls/wininet/http.c	28 Mar 2004 05:33:00 -0000
@@ -55,16 +55,22 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
 
-#define HTTPHEADER " HTTP/1.0"
-#define HTTPHOSTHEADER "\r\nHost: "
+const WCHAR g_szHttp[] = {' ','H','T','T','P','/','1','.','0',0 };
+const WCHAR g_szHost[] = {'\r','\n','H','o','s','t',':',' ',0 };
+const WCHAR g_szReferer[] = {'R','e','f','e','r','e','r',0};
+const WCHAR g_szAccept[] = {'A','c','c','e','p','t',0};
+const WCHAR g_szUserAgent[] = {'U','s','e','r','-','A','g','e','n','t',0};
+
+
+#define HTTPHEADER g_szHttp
+#define HTTPHOSTHEADER g_szHost
 #define MAXHOSTNAME 100
 #define MAX_FIELD_VALUE_LEN 256
 #define MAX_FIELD_LEN 256
 
-
-#define HTTP_REFERER    "Referer"
-#define HTTP_ACCEPT     "Accept"
-#define HTTP_USERAGENT  "User-Agent"
+#define HTTP_REFERER    g_szReferer
+#define HTTP_ACCEPT     g_szAccept
+#define HTTP_USERAGENT  g_szUserAgent
 
 #define HTTP_ADDHDR_FLAG_ADD				0x20000000
 #define HTTP_ADDHDR_FLAG_ADD_IF_NEW			0x10000000
@@ -75,22 +81,22 @@
 #define HTTP_ADDHDR_FLAG_REQ				0x02000000
 
 
-BOOL HTTP_OpenConnection(LPWININETHTTPREQA lpwhr);
-int HTTP_WriteDataToStream(LPWININETHTTPREQA lpwhr,
+BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr);
+int HTTP_WriteDataToStream(LPWININETHTTPREQW lpwhr,
 	void *Buffer, int BytesToWrite);
-int HTTP_ReadDataFromStream(LPWININETHTTPREQA lpwhr,
+int HTTP_ReadDataFromStream(LPWININETHTTPREQW lpwhr,
 	void *Buffer, int BytesToRead);
-BOOL HTTP_GetResponseHeaders(LPWININETHTTPREQA lpwhr);
-BOOL HTTP_ProcessHeader(LPWININETHTTPREQA lpwhr, LPCSTR field, LPCSTR value, DWORD dwModifier);
-void HTTP_CloseConnection(LPWININETHTTPREQA lpwhr);
-BOOL HTTP_InterpretHttpHeader(LPSTR buffer, LPSTR field, INT fieldlen, LPSTR value, INT valuelen);
-INT HTTP_GetStdHeaderIndex(LPCSTR lpszField);
-BOOL HTTP_InsertCustomHeader(LPWININETHTTPREQA lpwhr, LPHTTPHEADERA lpHdr);
-INT HTTP_GetCustomHeaderIndex(LPWININETHTTPREQA lpwhr, LPCSTR lpszField);
-BOOL HTTP_DeleteCustomHeader(LPWININETHTTPREQA lpwhr, INT index);
+BOOL HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr);
+BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR value, DWORD dwModifier);
+void HTTP_CloseConnection(LPWININETHTTPREQW lpwhr);
+BOOL HTTP_InterpretHttpHeader(LPWSTR buffer, LPWSTR field, INT fieldlen, LPWSTR value, INT valuelen);
+INT HTTP_GetStdHeaderIndex(LPCWSTR lpszField);
+BOOL HTTP_InsertCustomHeader(LPWININETHTTPREQW lpwhr, LPHTTPHEADERW lpHdr);
+INT HTTP_GetCustomHeaderIndex(LPWININETHTTPREQW lpwhr, LPCWSTR lpszField);
+BOOL HTTP_DeleteCustomHeader(LPWININETHTTPREQW lpwhr, INT index);
 
 /***********************************************************************
- *           HttpAddRequestHeadersA (WININET.@)
+ *           HttpAddRequestHeadersW (WININET.@)
  *
  * Adds one or more HTTP header to the request handler
  *
@@ -99,20 +105,20 @@
  *    FALSE on failure
  *
  */
-BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
-	LPCSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
+BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest,
+	LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
 {
-    LPSTR lpszStart;
-    LPSTR lpszEnd;
-    LPSTR buffer;
-    CHAR value[MAX_FIELD_VALUE_LEN], field[MAX_FIELD_LEN];
+    LPWSTR lpszStart;
+    LPWSTR lpszEnd;
+    LPWSTR buffer;
+    WCHAR value[MAX_FIELD_VALUE_LEN], field[MAX_FIELD_LEN];
     BOOL bSuccess = FALSE;
-    LPWININETHTTPREQA lpwhr;
+    LPWININETHTTPREQW lpwhr;
 
-    TRACE("%p, %s, %li, %li\n", hHttpRequest, lpszHeader, dwHeaderLength,
+    TRACE("%p, %s, %li, %li\n", hHttpRequest, debugstr_w(lpszHeader), dwHeaderLength,
           dwModifier);
 
-    lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
+    lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hHttpRequest );
 
     if (NULL == lpwhr ||  lpwhr->hdr.htype != WH_HHTTPREQ)
     {
@@ -123,8 +129,8 @@
     if (!lpszHeader) 
       return TRUE;
 
-    TRACE("copying header: %s\n", lpszHeader);
-    buffer = WININET_strdup(lpszHeader);
+    TRACE("copying header: %s\n", debugstr_w(lpszHeader));
+    buffer = WININET_strdupW(lpszHeader);
     lpszStart = buffer;
 
     do
@@ -143,7 +149,7 @@
 
         *lpszEnd = '\0';
 
-        TRACE("interpreting header %s\n", debugstr_a(lpszStart));
+        TRACE("interpreting header %s\n", debugstr_w(lpszStart));
         if (HTTP_InterpretHttpHeader(lpszStart, field, MAX_FIELD_LEN, value, MAX_FIELD_VALUE_LEN))
             bSuccess = HTTP_ProcessHeader(lpwhr, field, value, dwModifier | HTTP_ADDHDR_FLAG_REQ);
 
@@ -156,6 +162,39 @@
 }
 
 /***********************************************************************
+ *           HttpAddRequestHeadersA (WININET.@)
+ *
+ * Adds one or more HTTP header to the request handler
+ *
+ * RETURNS
+ *    TRUE  on success
+ *    FALSE on failure
+ *
+ */
+BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
+	LPCSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
+{
+    DWORD len;
+    LPWSTR hdr;
+    BOOL r;
+
+    TRACE("%p, %s, %li, %li\n", hHttpRequest, debugstr_a(lpszHeader), dwHeaderLength,
+          dwModifier);
+
+    len = MultiByteToWideChar( CP_ACP, 0, lpszHeader, dwHeaderLength, NULL, 0 );
+    hdr = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
+    MultiByteToWideChar( CP_ACP, 0, lpszHeader, dwHeaderLength, hdr, len );
+    if( dwHeaderLength != -1 )
+        dwHeaderLength = len;
+
+    r = HttpAddRequestHeadersW( hHttpRequest, hdr, dwHeaderLength, dwModifier );
+
+    HeapFree( GetProcessHeap(), 0, hdr );
+
+    return r;
+}
+
+/***********************************************************************
  *           HttpEndRequestA (WININET.@)
  *
  * Ends an HTTP request that was started by HttpSendRequestEx
@@ -190,7 +229,7 @@
 }
 
 /***********************************************************************
- *           HttpOpenRequestA (WININET.@)
+ *           HttpOpenRequestW (WININET.@)
  *
  * Open a HTTP request handle
  *
@@ -199,27 +238,27 @@
  *    NULL 	 on failure
  *
  */
-HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
-	LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion,
-	LPCSTR lpszReferrer , LPCSTR *lpszAcceptTypes,
+HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession,
+	LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
+	LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
 	DWORD dwFlags, DWORD dwContext)
 {
-    LPWININETHTTPSESSIONA lpwhs;
+    LPWININETHTTPSESSIONW lpwhs;
     LPWININETAPPINFOW hIC = NULL;
     HINTERNET handle = NULL;
 
     TRACE("(%p, %s, %s, %s, %s, %p, %08lx, %08lx)\n", hHttpSession,
-          debugstr_a(lpszVerb), lpszObjectName,
-          debugstr_a(lpszVersion), debugstr_a(lpszReferrer), lpszAcceptTypes,
+          debugstr_w(lpszVerb), debugstr_w(lpszObjectName),
+          debugstr_w(lpszVersion), debugstr_w(lpszReferrer), lpszAcceptTypes,
           dwFlags, dwContext);
     if(lpszAcceptTypes!=NULL)
     {
         int i;
         for(i=0;lpszAcceptTypes[i]!=NULL;i++)
-            TRACE("\taccept type: %s\n",lpszAcceptTypes[i]);
+            TRACE("\taccept type: %s\n",debugstr_w(lpszAcceptTypes[i]));
     }    
 
-    lpwhs = (LPWININETHTTPSESSIONA) WININET_GetObject( hHttpSession );
+    lpwhs = (LPWININETHTTPSESSIONW) WININET_GetObject( hHttpSession );
     if (NULL == lpwhs ||  lpwhs->hdr.htype != WH_HHTTPSESSION)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
@@ -240,19 +279,19 @@
     if (0)
     {
         WORKREQUEST workRequest;
-        struct WORKREQ_HTTPOPENREQUESTA *req;
+        struct WORKREQ_HTTPOPENREQUESTW *req;
 
-	workRequest.asyncall = HTTPOPENREQUESTA;
+	workRequest.asyncall = HTTPOPENREQUESTW;
 	workRequest.handle = hHttpSession;
-        req = &workRequest.u.HttpOpenRequestA;
-	req->lpszVerb = WININET_strdup(lpszVerb);
-	req->lpszObjectName = WININET_strdup(lpszObjectName);
+        req = &workRequest.u.HttpOpenRequestW;
+	req->lpszVerb = WININET_strdupW(lpszVerb);
+	req->lpszObjectName = WININET_strdupW(lpszObjectName);
         if (lpszVersion)
-            req->lpszVersion = WININET_strdup(lpszVersion);
+            req->lpszVersion = WININET_strdupW(lpszVersion);
         else
             req->lpszVersion = 0;
         if (lpszReferrer)
-            req->lpszReferrer = WININET_strdup(lpszReferrer);
+            req->lpszReferrer = WININET_strdupW(lpszReferrer);
         else
             req->lpszReferrer = 0;
 	req->lpszAcceptTypes = lpszAcceptTypes;
@@ -263,7 +302,7 @@
     }
     else
     {
-        handle = HTTP_HttpOpenRequestA(hHttpSession, lpszVerb, lpszObjectName,
+        handle = HTTP_HttpOpenRequestW(hHttpSession, lpszVerb, lpszObjectName,
                                               lpszVersion, lpszReferrer, lpszAcceptTypes,
                                               dwFlags, dwContext);
     }
@@ -273,7 +312,7 @@
 
 
 /***********************************************************************
- *           HttpOpenRequestW (WININET.@)
+ *           HttpOpenRequestA (WININET.@)
  *
  * Open a HTTP request handle
  *
@@ -281,83 +320,84 @@
  *    HINTERNET  a HTTP request handle on success
  *    NULL 	 on failure
  *
- * FIXME: This should be the other way around (A should call W)
  */
-HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession,
-	LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
-	LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
+HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
+	LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion,
+	LPCSTR lpszReferrer , LPCSTR *lpszAcceptTypes,
 	DWORD dwFlags, DWORD dwContext)
 {
-    CHAR *szVerb = NULL, *szObjectName = NULL;
-    CHAR *szVersion = NULL, *szReferrer = NULL, **szAcceptTypes = NULL;
+    LPWSTR szVerb = NULL, szObjectName = NULL;
+    LPWSTR szVersion = NULL, szReferrer = NULL, *szAcceptTypes = NULL;
     INT len;
     INT acceptTypesCount;
     HINTERNET rc = FALSE;
     TRACE("(%p, %s, %s, %s, %s, %p, %08lx, %08lx)\n", hHttpSession,
-          debugstr_w(lpszVerb), debugstr_w(lpszObjectName),
-          debugstr_w(lpszVersion), debugstr_w(lpszReferrer), lpszAcceptTypes,
+          debugstr_a(lpszVerb), debugstr_a(lpszObjectName),
+          debugstr_a(lpszVersion), debugstr_a(lpszReferrer), lpszAcceptTypes,
           dwFlags, dwContext);
 
     if (lpszVerb)
     {
-        len = WideCharToMultiByte(CP_ACP, 0, lpszVerb, -1, NULL, 0, NULL, NULL);
-        szVerb = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR) );
+        len = MultiByteToWideChar(CP_ACP, 0, lpszVerb, -1, NULL, 0 );
+        szVerb = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR) );
         if ( !szVerb )
             goto end;
-        WideCharToMultiByte(CP_ACP, 0, lpszVerb, -1, szVerb, len, NULL, NULL);
+        MultiByteToWideChar(CP_ACP, 0, lpszVerb, -1, szVerb, len);
     }
 
     if (lpszObjectName)
     {
-        len = WideCharToMultiByte(CP_ACP, 0, lpszObjectName, -1, NULL, 0, NULL, NULL);
-        szObjectName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR) );
+        len = MultiByteToWideChar(CP_ACP, 0, lpszObjectName, -1, NULL, 0 );
+        szObjectName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR) );
         if ( !szObjectName )
             goto end;
-        WideCharToMultiByte(CP_ACP, 0, lpszObjectName, -1, szObjectName, len, NULL, NULL);
+        MultiByteToWideChar(CP_ACP, 0, lpszObjectName, -1, szObjectName, len );
     }
 
     if (lpszVersion)
     {
-        len = WideCharToMultiByte(CP_ACP, 0, lpszVersion, -1, NULL, 0, NULL, NULL);
-        szVersion = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR));
+        len = MultiByteToWideChar(CP_ACP, 0, lpszVersion, -1, NULL, 0 );
+        szVersion = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
         if ( !szVersion )
             goto end;
-        WideCharToMultiByte(CP_ACP, 0, lpszVersion, -1, szVersion, len, NULL, NULL);
+        MultiByteToWideChar(CP_ACP, 0, lpszVersion, -1, szVersion, len );
     }
 
     if (lpszReferrer)
     {
-        len = WideCharToMultiByte(CP_ACP, 0, lpszReferrer, -1, NULL, 0, NULL, NULL);
-        szReferrer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR));
+        len = MultiByteToWideChar(CP_ACP, 0, lpszReferrer, -1, NULL, 0 );
+        szReferrer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
         if ( !szReferrer )
             goto end;
-        WideCharToMultiByte(CP_ACP, 0, lpszReferrer, -1, szReferrer, len, NULL, NULL);
+        MultiByteToWideChar(CP_ACP, 0, lpszReferrer, -1, szReferrer, len );
     }
 
     acceptTypesCount = 0;
     if (lpszAcceptTypes)
     {
-        while (lpszAcceptTypes[acceptTypesCount]) { acceptTypesCount++; } /* find out how many there are */
-        szAcceptTypes = HeapAlloc(GetProcessHeap(), 0, sizeof(CHAR*)*(acceptTypesCount+1));
+        /* find out how many there are */
+        while (lpszAcceptTypes[acceptTypesCount]) 
+            acceptTypesCount++;
+        szAcceptTypes = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR *) * (acceptTypesCount+1));
         acceptTypesCount = 0;
         while (lpszAcceptTypes[acceptTypesCount])
         {
-            len = WideCharToMultiByte(CP_ACP, 0, lpszAcceptTypes[acceptTypesCount],
-                                -1, NULL, 0, NULL, NULL);
-            szAcceptTypes[acceptTypesCount] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR));
+            len = MultiByteToWideChar(CP_ACP, 0, lpszAcceptTypes[acceptTypesCount],
+                                -1, NULL, 0 );
+            szAcceptTypes[acceptTypesCount] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
             if (!szAcceptTypes[acceptTypesCount] )
                 goto end;
-            WideCharToMultiByte(CP_ACP, 0, lpszAcceptTypes[acceptTypesCount],
-                                -1, szAcceptTypes[acceptTypesCount], len, NULL, NULL);
+            MultiByteToWideChar(CP_ACP, 0, lpszAcceptTypes[acceptTypesCount],
+                                -1, szAcceptTypes[acceptTypesCount], len );
             acceptTypesCount++;
         }
-	szAcceptTypes[acceptTypesCount] = NULL;
+        szAcceptTypes[acceptTypesCount] = NULL;
     }
     else szAcceptTypes = 0;
 
-    rc = HttpOpenRequestA(hHttpSession, (LPCSTR)szVerb, (LPCSTR)szObjectName,
-                          (LPCSTR)szVersion, (LPCSTR)szReferrer,
-                          (LPCSTR *)szAcceptTypes, dwFlags, dwContext);
+    rc = HttpOpenRequestW(hHttpSession, szVerb, szObjectName,
+                          szVersion, szReferrer,
+                          (LPCWSTR*)szAcceptTypes, dwFlags, dwContext);
 
 end:
     if (szAcceptTypes)
@@ -440,7 +480,7 @@
 
     len = lstrlenW(szBasic) +
           (lstrlenW( username ) + 1 + lstrlenW ( password ))*2 + 1 + 1;
-    out = HeapAlloc( GetProcessHeap(), 0, len );
+    out = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
     if( out )
     {
         lstrcpyW( in, username );
@@ -459,27 +499,23 @@
  *
  *   Insert the basic authorization field in the request header
  */
-BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQA lpwhr,
+BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
                        LPCWSTR username, LPCWSTR password )
 {
-    HTTPHEADERA hdr;
-    INT index, len;
-    LPWSTR authW;
-
-    authW = HTTP_EncodeBasicAuth( username, password );
-
-    len = WideCharToMultiByte( CP_ACP, 0, authW, -1, NULL, 0, NULL, NULL);
-    hdr.lpszValue = HeapAlloc( GetProcessHeap(), 0, len );
-    WideCharToMultiByte( CP_ACP, 0, authW, -1, hdr.lpszValue, len, NULL, NULL);
+    HTTPHEADERW hdr;
+    INT index;
+    WCHAR szProxyAuthorization[] = {
+        'P','r','o','x','y','-','A','u','t','h','o','r','i','z','a','t','i','o','n',0 };
 
-    hdr.lpszField = "Proxy-Authorization";
+    hdr.lpszValue = HTTP_EncodeBasicAuth( username, password );
+    hdr.lpszField = szProxyAuthorization;
     hdr.wFlags = HDR_ISREQUEST;
     hdr.wCount = 0;
     if( !hdr.lpszValue )
         return FALSE;
 
     TRACE("Inserting %s = %s\n",
-          debugstr_a( hdr.lpszField ), debugstr_a( hdr.lpszValue ) );
+          debugstr_w( hdr.lpszField ), debugstr_w( hdr.lpszValue ) );
 
     /* remove the old proxy authorization header */
     index = HTTP_GetCustomHeaderIndex( lpwhr, hdr.lpszField );
@@ -488,7 +524,6 @@
     
     HTTP_InsertCustomHeader(lpwhr, &hdr);
     HeapFree( GetProcessHeap(), 0, hdr.lpszValue );
-    HeapFree( GetProcessHeap(), 0, authW );
     
     return TRUE;
 }
@@ -497,24 +532,29 @@
  *           HTTP_DealWithProxy
  */
 static BOOL HTTP_DealWithProxy( LPWININETAPPINFOW hIC,
-    LPWININETHTTPSESSIONA lpwhs, LPWININETHTTPREQA lpwhr)
+    LPWININETHTTPSESSIONW lpwhs, LPWININETHTTPREQW lpwhr)
 {
-    char buf[MAXHOSTNAME];
-    char proxy[MAXHOSTNAME + 15]; /* 15 == "http://" + sizeof(port#) + ":/\0" */
-    char* url, *szNul = "";
-    URL_COMPONENTSA UrlComponents;
+    WCHAR buf[MAXHOSTNAME];
+    WCHAR proxy[MAXHOSTNAME + 15]; /* 15 == "http://" + sizeof(port#) + ":/\0" */
+    WCHAR* url, szNul[] = { 0 };
+    URL_COMPONENTSW UrlComponents;
+    WCHAR szHttp[] = { 'h','t','t','p',':','/','/',0 }, szSlash[] = { '/',0 } ;
+    //WCHAR szColon[] = { ':',0 };
+    WCHAR szFormat1[] = { 'h','t','t','p',':','/','/','%','s',':','%','d',0 };
+    WCHAR szFormat2[] = { 'h','t','t','p',':','/','/','%','s',':','%','d',0 };
+    int len;
 
     memset( &UrlComponents, 0, sizeof UrlComponents );
     UrlComponents.dwStructSize = sizeof UrlComponents;
     UrlComponents.lpszHostName = buf;
     UrlComponents.dwHostNameLength = MAXHOSTNAME;
 
-    WideCharToMultiByte(CP_ACP, 0, hIC->lpszProxy, -1, buf, sizeof buf, NULL, NULL);
-    if (strncasecmp(buf,"http://",strlen("http://")))
-	sprintf(proxy, "http://%s/", buf);
+    if( CSTR_EQUAL != CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
+                                 buf,strlenW(szHttp),szHttp,strlenW(szHttp)) )
+        sprintfW(proxy, szFormat1, hIC->lpszProxy);
     else
-	strcpy(proxy,buf);
-    if( !InternetCrackUrlA(proxy, 0, 0, &UrlComponents) )
+	strcpyW(proxy,buf);
+    if( !InternetCrackUrlW(proxy, 0, 0, &UrlComponents) )
         return FALSE;
     if( UrlComponents.dwHostNameLength == 0 )
         return FALSE;
@@ -522,31 +562,31 @@
     if( !lpwhr->lpszPath )
         lpwhr->lpszPath = szNul;
     TRACE("server='%s' path='%s'\n",
-          lpwhs->lpszServerName, lpwhr->lpszPath);
+          debugstr_w(lpwhs->lpszServerName), debugstr_w(lpwhr->lpszPath));
     /* for constant 15 see above */
-    url = HeapAlloc(GetProcessHeap(), 0,
-        strlen(lpwhs->lpszServerName) + strlen(lpwhr->lpszPath) + 15);
+    len = strlenW(lpwhs->lpszServerName) + strlenW(lpwhr->lpszPath) + 15;
+    url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
 
     if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER)
         UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
 
-    sprintf(url, "http://%s:%d", lpwhs->lpszServerName,
-            lpwhs->nServerPort);
+    sprintfW(url, szFormat2, lpwhs->lpszServerName, lpwhs->nServerPort);
+
     if( lpwhr->lpszPath[0] != '/' )
-        strcat( url, "/" );
-    strcat(url, lpwhr->lpszPath);
+        strcatW( url, szSlash );
+    strcatW(url, lpwhr->lpszPath);
     if(lpwhr->lpszPath != szNul)
         HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);
     lpwhr->lpszPath = url;
     /* FIXME: Do I have to free lpwhs->lpszServerName here ? */
-    lpwhs->lpszServerName = WININET_strdup(UrlComponents.lpszHostName);
+    lpwhs->lpszServerName = WININET_strdupW(UrlComponents.lpszHostName);
     lpwhs->nServerPort = UrlComponents.nPort;
 
     return TRUE;
 }
 
 /***********************************************************************
- *           HTTP_HttpOpenRequestA (internal)
+ *           HTTP_HttpOpenRequestW (internal)
  *
  * Open a HTTP request handle
  *
@@ -555,22 +595,24 @@
  *    NULL 	 on failure
  *
  */
-HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
-	LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion,
-	LPCSTR lpszReferrer , LPCSTR *lpszAcceptTypes,
+HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
+	LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
+	LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
 	DWORD dwFlags, DWORD dwContext)
 {
-    LPWININETHTTPSESSIONA lpwhs;
+    LPWININETHTTPSESSIONW lpwhs;
     LPWININETAPPINFOW hIC = NULL;
-    LPWININETHTTPREQA lpwhr;
-    LPSTR lpszCookies;
-    LPSTR lpszUrl = NULL;
+    LPWININETHTTPREQW lpwhr;
+    LPWSTR lpszCookies;
+    LPWSTR lpszUrl = NULL;
     DWORD nCookieSize;
     HINTERNET handle;
+    WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0};
+    DWORD len;
 
     TRACE("--> \n");
 
-    lpwhs = (LPWININETHTTPSESSIONA) WININET_GetObject( hHttpSession );
+    lpwhs = (LPWININETHTTPSESSIONW) WININET_GetObject( hHttpSession );
     if (NULL == lpwhs ||  lpwhs->hdr.htype != WH_HHTTPSESSION)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
@@ -579,7 +621,7 @@
 
     hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
 
-    lpwhr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPREQA));
+    lpwhr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPREQW));
     if (NULL == lpwhr)
     {
         INTERNET_SetLastError(ERROR_OUTOFMEMORY);
@@ -599,23 +641,24 @@
     lpwhr->hdr.dwContext = dwContext;
     NETCON_init(&lpwhr->netConnection, dwFlags & INTERNET_FLAG_SECURE);
 
-    if (NULL != lpszObjectName && strlen(lpszObjectName)) {
-        DWORD needed = 0;
+    if (NULL != lpszObjectName && strlenW(lpszObjectName)) {
         HRESULT rc;
-        rc = UrlEscapeA(lpszObjectName, NULL, &needed, URL_ESCAPE_SPACES_ONLY);
+
+        len = 0;
+        rc = UrlEscapeW(lpszObjectName, NULL, &len, URL_ESCAPE_SPACES_ONLY);
         if (rc != E_POINTER)
-            needed = strlen(lpszObjectName)+1;
-        lpwhr->lpszPath = HeapAlloc(GetProcessHeap(), 0, needed);
-        rc = UrlEscapeA(lpszObjectName, lpwhr->lpszPath, &needed,
+            len = strlenW(lpszObjectName)+1;
+        lpwhr->lpszPath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+        rc = UrlEscapeW(lpszObjectName, lpwhr->lpszPath, &len,
                    URL_ESCAPE_SPACES_ONLY);
         if (rc)
         {
-            ERR("Unable to escape string!(%s) (%ld)\n",lpszObjectName,rc);
-            strcpy(lpwhr->lpszPath,lpszObjectName);
+            ERR("Unable to escape string!(%s) (%ld)\n",debugstr_w(lpszObjectName),rc);
+            strcpyW(lpwhr->lpszPath,lpszObjectName);
         }
     }
 
-    if (NULL != lpszReferrer && strlen(lpszReferrer))
+    if (NULL != lpszReferrer && strlenW(lpszReferrer))
         HTTP_ProcessHeader(lpwhr, HTTP_REFERER, lpszReferrer, HTTP_ADDHDR_FLAG_COALESCE);
 
     if(lpszAcceptTypes!=NULL)
@@ -626,60 +669,63 @@
     }
 
     if (NULL == lpszVerb)
-        lpwhr->lpszVerb = WININET_strdup("GET");
-    else if (strlen(lpszVerb))
-        lpwhr->lpszVerb = WININET_strdup(lpszVerb);
+    {
+        WCHAR szGet[] = {'G','E','T',0};
+        lpwhr->lpszVerb = WININET_strdupW(szGet);
+    }
+    else if (strlenW(lpszVerb))
+        lpwhr->lpszVerb = WININET_strdupW(lpszVerb);
 
-    if (NULL != lpszReferrer && strlen(lpszReferrer))
+    if (NULL != lpszReferrer && strlenW(lpszReferrer))
     {
-        char buf[MAXHOSTNAME];
-        URL_COMPONENTSA UrlComponents;
+        WCHAR buf[MAXHOSTNAME];
+        URL_COMPONENTSW UrlComponents;
 
         memset( &UrlComponents, 0, sizeof UrlComponents );
         UrlComponents.dwStructSize = sizeof UrlComponents;
         UrlComponents.lpszHostName = buf;
         UrlComponents.dwHostNameLength = MAXHOSTNAME;
 
-        InternetCrackUrlA(lpszReferrer, 0, 0, &UrlComponents);
-        if (strlen(UrlComponents.lpszHostName))
-            lpwhr->lpszHostName = WININET_strdup(UrlComponents.lpszHostName);
+        InternetCrackUrlW(lpszReferrer, 0, 0, &UrlComponents);
+        if (strlenW(UrlComponents.lpszHostName))
+            lpwhr->lpszHostName = WININET_strdupW(UrlComponents.lpszHostName);
     } else {
-        lpwhr->lpszHostName = WININET_strdup(lpwhs->lpszServerName);
+        lpwhr->lpszHostName = WININET_strdupW(lpwhs->lpszServerName);
     }
     if (NULL != hIC->lpszProxy && hIC->lpszProxy[0] != 0)
         HTTP_DealWithProxy( hIC, lpwhs, lpwhr );
 
     if (hIC->lpszAgent)
     {
-        int len = WideCharToMultiByte(CP_ACP, 0, hIC->lpszAgent, -1, NULL, 0, NULL, NULL );
-        char *agent_header, *user_agent = "User-Agent: ";
+        WCHAR *agent_header;
+        WCHAR user_agent[] = {'U','s','e','r','-','A','g','e','n','t',':',' ','%','s','\r','\n',0 };
 
-        agent_header = HeapAlloc( GetProcessHeap(), 0, 
-                                  strlen(user_agent) + len + 3 );
-        strcpy(agent_header, user_agent);
-        WideCharToMultiByte(CP_ACP, 0, hIC->lpszAgent, -1,
-                            agent_header+strlen(user_agent), len, NULL, NULL );
-        strcat(agent_header, "\r\n");
+        len = strlenW(hIC->lpszAgent) + strlenW(user_agent);
+        agent_header = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
+        sprintfW(agent_header, user_agent, hIC->lpszAgent );
 
-        HttpAddRequestHeadersA(handle, agent_header, strlen(agent_header),
+        HttpAddRequestHeadersW(handle, agent_header, strlenW(agent_header),
                                HTTP_ADDREQ_FLAG_ADD);
         HeapFree(GetProcessHeap(), 0, agent_header);
     }
 
-    lpszUrl = HeapAlloc(GetProcessHeap(), 0, strlen(lpwhr->lpszHostName) + 1 + strlen("http://"));
-    sprintf(lpszUrl, "http://%s", lpwhr->lpszHostName);
-    if (InternetGetCookieA(lpszUrl, NULL, NULL, &nCookieSize))
+    len = strlenW(lpwhr->lpszHostName) + strlenW(szUrlForm);
+    lpszUrl = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+    sprintfW( lpszUrl, szUrlForm, lpwhr->lpszHostName );
+
+    if (InternetGetCookieW(lpszUrl, NULL, NULL, &nCookieSize))
     {
         int cnt = 0;
+        WCHAR szCookie[] = {'C','o','o','k','i','e',':',' ',0};
+        WCHAR szcrlf[] = {'\r','\n',0};
 
-        lpszCookies = HeapAlloc(GetProcessHeap(), 0, nCookieSize + strlen("Cookie: ") + strlen("\r\n") + 1);
+        lpszCookies = HeapAlloc(GetProcessHeap(), 0, (nCookieSize + 1 + 8)*sizeof(WCHAR));
 
-        cnt += sprintf(lpszCookies, "Cookie: ");
-        InternetGetCookieA(lpszUrl, NULL, lpszCookies + cnt, &nCookieSize);
-        cnt += nCookieSize - 1;
-        sprintf(lpszCookies + cnt, "\r\n");
+        cnt += sprintfW(lpszCookies, szCookie);
+        InternetGetCookieW(lpszUrl, NULL, lpszCookies + cnt, &nCookieSize);
+        strcatW(lpszCookies, szcrlf);
 
-        HttpAddRequestHeadersA(handle, lpszCookies, strlen(lpszCookies),
+        HttpAddRequestHeadersW(handle, lpszCookies, strlenW(lpszCookies),
                                HTTP_ADDREQ_FLAG_ADD);
         HeapFree(GetProcessHeap(), 0, lpszCookies);
     }
@@ -709,7 +755,7 @@
     SendAsyncCallback(hIC, hHttpSession, dwContext,
                       INTERNET_STATUS_RESOLVING_NAME,
                       lpwhs->lpszServerName,
-                      strlen(lpwhs->lpszServerName)+1);
+                      strlenW(lpwhs->lpszServerName)+1);
     if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
                     &lpwhs->phostent, &lpwhs->socketAddress))
     {
@@ -737,12 +783,15 @@
  *    FALSE on failure
  *
  */
-BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
+BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel,
 	LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
 {
-    LPHTTPHEADERA lphttpHdr = NULL;
+    LPHTTPHEADERW lphttpHdr = NULL;
     BOOL bSuccess = FALSE;
-    LPWININETHTTPREQA lpwhr;
+    LPWININETHTTPREQW lpwhr;
+    WCHAR szFmt[] = { '%','s',':',' ','%','s','%','s',0 };
+    WCHAR szcrlf[] = { '\r','\n',0 };
+    WCHAR sznul[] = { 0 };
 
     if (TRACE_ON(wininet)) {
 #define FE(x) { x, #x }
@@ -854,7 +903,7 @@
 	DPRINTF("\n");
     }
     
-    lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
+    lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hHttpRequest );
     if (NULL == lpwhr ||  lpwhr->hdr.htype != WH_HHTTPREQ)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
@@ -864,7 +913,7 @@
     /* Find requested header structure */
     if ((dwInfoLevel & ~HTTP_QUERY_MODIFIER_FLAGS_MASK) == HTTP_QUERY_CUSTOM)
     {
-        INT index = HTTP_GetCustomHeaderIndex(lpwhr, (LPSTR)lpBuffer);
+        INT index = HTTP_GetCustomHeaderIndex(lpwhr, (LPWSTR)lpBuffer);
 
         if (index < 0)
             goto lend;
@@ -887,8 +936,8 @@
                if ((~lpwhr->pCustHeaders[i].wFlags & HDR_ISREQUEST) && lpwhr->pCustHeaders[i].lpszField &&
 		   lpwhr->pCustHeaders[i].lpszValue)
 	       {
-                  size += strlen(lpwhr->pCustHeaders[i].lpszField) +
-                       strlen(lpwhr->pCustHeaders[i].lpszValue) + delim + 2;
+                  size += strlenW(lpwhr->pCustHeaders[i].lpszField) +
+                       strlenW(lpwhr->pCustHeaders[i].lpszValue) + delim + 2;
 	       }
            }
 
@@ -898,8 +947,8 @@
               if ((~lpwhr->StdHeaders[i].wFlags & HDR_ISREQUEST) && lpwhr->StdHeaders[i].lpszField &&
                    lpwhr->StdHeaders[i].lpszValue)
               {
-                 size += strlen(lpwhr->StdHeaders[i].lpszField) +
-                    strlen(lpwhr->StdHeaders[i].lpszValue) + delim + 2;
+                 size += strlenW(lpwhr->StdHeaders[i].lpszField) +
+                    strlenW(lpwhr->StdHeaders[i].lpszValue) + delim + 2;
               }
            }
            size += delim;
@@ -918,8 +967,9 @@
 					   lpwhr->StdHeaders[i].lpszField &&
 					   lpwhr->StdHeaders[i].lpszValue)
                {
-                   cnt += sprintf((char*)lpBuffer + cnt, "%s: %s%s", lpwhr->StdHeaders[i].lpszField, lpwhr->StdHeaders[i].lpszValue,
-                          index == HTTP_QUERY_RAW_HEADERS_CRLF ? "\r\n" : "\0");
+                   cnt += sprintfW((WCHAR*)lpBuffer + cnt, szFmt, 
+                            lpwhr->StdHeaders[i].lpszField, lpwhr->StdHeaders[i].lpszValue,
+                          index == HTTP_QUERY_RAW_HEADERS_CRLF ? szcrlf : sznul );
                }
             }
 
@@ -930,13 +980,13 @@
 						lpwhr->pCustHeaders[i].lpszField &&
 						lpwhr->pCustHeaders[i].lpszValue)
                 {
-                   cnt += sprintf((char*)lpBuffer + cnt, "%s: %s%s",
+                   cnt += sprintfW((WCHAR*)lpBuffer + cnt, szFmt,
                     lpwhr->pCustHeaders[i].lpszField, lpwhr->pCustHeaders[i].lpszValue,
-					index == HTTP_QUERY_RAW_HEADERS_CRLF ? "\r\n" : "\0");
+					index == HTTP_QUERY_RAW_HEADERS_CRLF ? szcrlf : sznul);
                 }
             }
 
-            strcpy((char*)lpBuffer + cnt, index == HTTP_QUERY_RAW_HEADERS_CRLF ? "\r\n" : "");
+            strcpyW((WCHAR*)lpBuffer + cnt, index == HTTP_QUERY_RAW_HEADERS_CRLF ? szcrlf : sznul);
 
            *lpdwBufferLength = cnt + delim;
            bSuccess = TRUE;
@@ -958,7 +1008,7 @@
     /* coalesce value to reuqested type */
     if (dwInfoLevel & HTTP_QUERY_FLAG_NUMBER)
     {
-	*(int *)lpBuffer = atoi(lphttpHdr->lpszValue);
+	*(int *)lpBuffer = atoiW(lphttpHdr->lpszValue);
 	bSuccess = TRUE;
 
 	TRACE(" returning number : %d\n", *(int *)lpBuffer);
@@ -999,13 +1049,13 @@
 		}
 	    else
 	    {
-	    /* Copy strncpy(lpBuffer, lphttpHdr[*lpdwIndex], len); */
+	    /* Copy strncpyW(lpBuffer, lphttpHdr[*lpdwIndex], len); */
             (*lpdwIndex)++;
 	    }
     }
     else
     {
-        INT len = strlen(lphttpHdr->lpszValue);
+        INT len = strlenW(lphttpHdr->lpszValue);
 
         if (len + 1 > *lpdwBufferLength)
         {
@@ -1014,12 +1064,12 @@
             goto lend;
         }
 
-        strncpy(lpBuffer, lphttpHdr->lpszValue, len);
-        ((char*)lpBuffer)[len]=0;
+        strncpyW(lpBuffer, lphttpHdr->lpszValue, len);
+        ((WCHAR*)lpBuffer)[len]=0;
         *lpdwBufferLength = len;
         bSuccess = TRUE;
 
-	TRACE(" returning string : '%s'\n", debugstr_a(lpBuffer));
+	TRACE(" returning string : '%s'\n", debugstr_w(lpBuffer));
     }
 
 lend:
@@ -1028,7 +1078,7 @@
 }
 
 /***********************************************************************
- *           HttpQueryInfoW (WININET.@)
+ *           HttpQueryInfoA (WININET.@)
  *
  * Queries for information about an HTTP request
  *
@@ -1037,13 +1087,13 @@
  *    FALSE on failure
  *
  */
-BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel,
+BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
 	LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
 {
     BOOL result;
     DWORD charLen=*lpdwBufferLength;
-    char* tempBuffer=HeapAlloc(GetProcessHeap(), 0, charLen);
-    result=HttpQueryInfoA(hHttpRequest, dwInfoLevel, tempBuffer, &charLen, lpdwIndex);
+    WCHAR* tempBuffer=HeapAlloc(GetProcessHeap(), 0, charLen);
+    result=HttpQueryInfoW(hHttpRequest, dwInfoLevel, tempBuffer, &charLen, lpdwIndex);
     if((dwInfoLevel & HTTP_QUERY_FLAG_NUMBER) ||
        (dwInfoLevel & HTTP_QUERY_FLAG_SYSTEMTIME))
     {
@@ -1051,7 +1101,7 @@
     }
     else
     {
-        int nChars=MultiByteToWideChar(CP_ACP,0, tempBuffer,charLen,lpBuffer,*lpdwBufferLength);
+        int nChars=WideCharToMultiByte(CP_ACP,0, tempBuffer,charLen,lpBuffer,*lpdwBufferLength,NULL,NULL);
         *lpdwBufferLength=nChars;
     }
     HeapFree(GetProcessHeap(), 0, tempBuffer);
@@ -1084,24 +1134,24 @@
  *    FALSE on failure
  *
  */
-BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
+BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
 	DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength)
 {
-    LPWININETHTTPREQA lpwhr;
-    LPWININETHTTPSESSIONA lpwhs = NULL;
+    LPWININETHTTPREQW lpwhr;
+    LPWININETHTTPSESSIONW lpwhs = NULL;
     LPWININETAPPINFOW hIC = NULL;
 
     TRACE("%p, %p (%s), %li, %p, %li)\n", hHttpRequest,
-            lpszHeaders, debugstr_a(lpszHeaders), dwHeaderLength, lpOptional, dwOptionalLength);
+            lpszHeaders, debugstr_w(lpszHeaders), dwHeaderLength, lpOptional, dwOptionalLength);
 
-    lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
+    lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hHttpRequest );
     if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
 	return FALSE;
     }
 
-    lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
+    lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
     if (NULL == lpwhs ||  lpwhs->hdr.htype != WH_HHTTPSESSION)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
@@ -1118,13 +1168,13 @@
     if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
     {
         WORKREQUEST workRequest;
-        struct WORKREQ_HTTPSENDREQUESTA *req;
+        struct WORKREQ_HTTPSENDREQUESTW *req;
 
-        workRequest.asyncall = HTTPSENDREQUESTA;
+        workRequest.asyncall = HTTPSENDREQUESTW;
         workRequest.handle = hHttpRequest;
-        req = &workRequest.u.HttpSendRequestA;
+        req = &workRequest.u.HttpSendRequestW;
         if (lpszHeaders)
-            req->lpszHeader = WININET_strdup(lpszHeaders);
+            req->lpszHeader = WININET_strdupW(lpszHeaders);
         else
             req->lpszHeader = 0;
         req->dwHeaderLength = dwHeaderLength;
@@ -1140,7 +1190,7 @@
     }
     else
     {
-	return HTTP_HttpSendRequestA(hHttpRequest, lpszHeaders,
+	return HTTP_HttpSendRequestW(hHttpRequest, lpszHeaders,
 		dwHeaderLength, lpOptional, dwOptionalLength);
     }
 }
@@ -1155,19 +1205,19 @@
  *    FALSE on failure
  *
  */
-BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
+BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
 	DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength)
 {
     BOOL result;
-    char* szHeaders=NULL;
+    LPWSTR szHeaders=NULL;
     DWORD nLen=dwHeaderLength;
     if(lpszHeaders!=NULL)
     {
-        nLen=WideCharToMultiByte(CP_ACP,0,lpszHeaders,dwHeaderLength,NULL,0,NULL,NULL);
-        szHeaders=HeapAlloc(GetProcessHeap(),0,nLen);
-        WideCharToMultiByte(CP_ACP,0,lpszHeaders,dwHeaderLength,szHeaders,nLen,NULL,NULL);
+        nLen=MultiByteToWideChar(CP_ACP,0,lpszHeaders,dwHeaderLength,NULL,0);
+        szHeaders=HeapAlloc(GetProcessHeap(),0,nLen*sizeof(WCHAR));
+        MultiByteToWideChar(CP_ACP,0,lpszHeaders,dwHeaderLength,szHeaders,nLen);
     }
-    result=HttpSendRequestA(hHttpRequest, szHeaders, nLen, lpOptional, dwOptionalLength);
+    result=HttpSendRequestW(hHttpRequest, szHeaders, nLen, lpOptional, dwOptionalLength);
     if(szHeaders!=NULL)
         HeapFree(GetProcessHeap(),0,szHeaders);
     return result;
@@ -1176,30 +1226,30 @@
 /***********************************************************************
  *           HTTP_HandleRedirect (internal)
  */
-static BOOL HTTP_HandleRedirect(LPWININETHTTPREQA lpwhr, LPCSTR lpszUrl, LPCSTR lpszHeaders,
+static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWSTR lpszHeaders,
                                 DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
 {
-    LPWININETHTTPSESSIONA lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
+    LPWININETHTTPSESSIONW lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
     LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
-    char path[2048];
+    WCHAR path[2048];
     HINTERNET handle;
 
     if(lpszUrl[0]=='/')
     {
         /* if it's an absolute path, keep the same session info */
-        strcpy(path,lpszUrl);
+        strcpyW(path,lpszUrl);
     }
     else if (NULL != hIC->lpszProxy && hIC->lpszProxy[0] != 0)
     {
         TRACE("Redirect through proxy\n");
-        strcpy(path,lpszUrl);
+        strcpyW(path,lpszUrl);
     }
     else
     {
-        URL_COMPONENTSA urlComponents;
-        char protocol[32], hostName[MAXHOSTNAME], userName[1024];
-        char password[1024], extra[1024];
-        urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
+        URL_COMPONENTSW urlComponents;
+        WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
+        WCHAR password[1024], extra[1024];
+        urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
         urlComponents.lpszScheme = protocol;
         urlComponents.dwSchemeLength = 32;
         urlComponents.lpszHostName = hostName;
@@ -1212,7 +1262,7 @@
         urlComponents.dwUrlPathLength = 2048;
         urlComponents.lpszExtraInfo = extra;
         urlComponents.dwExtraInfoLength = 1024;
-        if(!InternetCrackUrlA(lpszUrl, strlen(lpszUrl), 0, &urlComponents))
+        if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents))
             return FALSE;
         
         if (urlComponents.nPort == INTERNET_INVALID_PORT_NUMBER)
@@ -1229,7 +1279,7 @@
          */
 
         /* consider the current host as the referrer */
-        if (NULL != lpwhs->lpszServerName && strlen(lpwhs->lpszServerName))
+        if (NULL != lpwhs->lpszServerName && strlenW(lpwhs->lpszServerName))
             HTTP_ProcessHeader(lpwhr, HTTP_REFERER, lpwhs->lpszServerName,
                            HTTP_ADDHDR_FLAG_REQ|HTTP_ADDREQ_FLAG_REPLACE|
                            HTTP_ADDHDR_FLAG_ADD_IF_NEW);
@@ -1237,20 +1287,20 @@
         
         if (NULL != lpwhs->lpszServerName)
             HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName);
-        lpwhs->lpszServerName = WININET_strdup(hostName);
+        lpwhs->lpszServerName = WININET_strdupW(hostName);
         if (NULL != lpwhs->lpszUserName)
             HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName);
-        lpwhs->lpszUserName = WININET_strdup(userName);
+        lpwhs->lpszUserName = WININET_strdupW(userName);
         lpwhs->nServerPort = urlComponents.nPort;
 
         if (NULL != lpwhr->lpszHostName)
             HeapFree(GetProcessHeap(), 0, lpwhr->lpszHostName);
-        lpwhr->lpszHostName=WININET_strdup(hostName);
+        lpwhr->lpszHostName=WININET_strdupW(hostName);
 
         SendAsyncCallback(hIC, lpwhs, lpwhr->hdr.dwContext,
                       INTERNET_STATUS_RESOLVING_NAME,
                       lpwhs->lpszServerName,
-                      strlen(lpwhs->lpszServerName)+1);
+                      strlenW(lpwhs->lpszServerName)+1);
 
         if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
                     &lpwhs->phostent, &lpwhs->socketAddress))
@@ -1269,29 +1319,30 @@
     if(lpwhr->lpszPath)
         HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);
     lpwhr->lpszPath=NULL;
-    if (strlen(path))
+    if (strlenW(path))
     {
         DWORD needed = 0;
         HRESULT rc;
-        rc = UrlEscapeA(path, NULL, &needed, URL_ESCAPE_SPACES_ONLY);
+
+        rc = UrlEscapeW(path, NULL, &needed, URL_ESCAPE_SPACES_ONLY);
         if (rc != E_POINTER)
-            needed = strlen(path)+1;
-        lpwhr->lpszPath = HeapAlloc(GetProcessHeap(), 0, needed);
-        rc = UrlEscapeA(path, lpwhr->lpszPath, &needed,
+            needed = strlenW(path)+1;
+        lpwhr->lpszPath = HeapAlloc(GetProcessHeap(), 0, needed*sizeof(WCHAR));
+        rc = UrlEscapeW(path, lpwhr->lpszPath, &needed,
                         URL_ESCAPE_SPACES_ONLY);
         if (rc)
         {
-            ERR("Unable to escape string!(%s) (%ld)\n",path,rc);
-            strcpy(lpwhr->lpszPath,path);
+            ERR("Unable to escape string!(%s) (%ld)\n",debugstr_w(path),rc);
+            strcpyW(lpwhr->lpszPath,path);
         }
     }
 
     handle = WININET_FindHandle( &lpwhr->hdr );
-    return HttpSendRequestA(handle, lpszHeaders, dwHeaderLength, lpOptional, dwOptionalLength);
+    return HttpSendRequestW(handle, lpszHeaders, dwHeaderLength, lpOptional, dwOptionalLength);
 }
 
 /***********************************************************************
- *           HTTP_HttpSendRequestA (internal)
+ *           HTTP_HttpSendRequestW (internal)
  *
  * Sends the specified request to the HTTP server
  *
@@ -1300,19 +1351,19 @@
  *    FALSE on failure
  *
  */
-BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
+BOOL WINAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
 	DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength)
 {
     INT cnt;
     INT i;
     BOOL bSuccess = FALSE;
-    LPSTR requestString = NULL;
-    LPSTR lpszHeaders_r_n = NULL; /* lpszHeaders with atleast one pair of \r\n at the end */
+    LPWSTR requestString = NULL;
+    LPWSTR lpszHeaders_r_n = NULL; /* lpszHeaders with atleast one pair of \r\n at the end */
     INT requestStringLen;
     INT responseLen;
     INT headerLength = 0;
-    LPWININETHTTPREQA lpwhr;
-    LPWININETHTTPSESSIONA lpwhs = NULL;
+    LPWININETHTTPREQW lpwhr;
+    LPWININETHTTPSESSIONW lpwhs = NULL;
     LPWININETAPPINFOW hIC = NULL;
     BOOL loop_next = FALSE;
     int CustHeaderIndex;
@@ -1320,14 +1371,14 @@
     TRACE("--> 0x%08lx\n", (ULONG)hHttpRequest);
 
     /* Verify our tree of internet handles */
-    lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
+    lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hHttpRequest );
     if (NULL == lpwhr ||  lpwhr->hdr.htype != WH_HHTTPREQ)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
 	return FALSE;
     }
 
-    lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
+    lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
     if (NULL == lpwhs ||  lpwhs->hdr.htype != WH_HHTTPSESSION)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
@@ -1361,39 +1412,43 @@
 
     do
     {
-        TRACE("Going to url %s %s\n", debugstr_a(lpwhr->lpszHostName), debugstr_a(lpwhr->lpszPath));
+        WCHAR szSlash[] = { '/',0 };
+        WCHAR szSpace[] = { ' ',0 };
+        WCHAR szHttp[] = { 'h','t','t','p',':','/','/', 0 };
+	WCHAR szcrlf[] = {'\r','\n', 0};
+	WCHAR sztwocrlf[] = {'\r','\n','\r','\n', 0};
+        WCHAR szSetCookie[] = {'S','e','t','-','C','o','o','k','i','e',0 };
+
+        TRACE("Going to url %s %s\n", debugstr_w(lpwhr->lpszHostName), debugstr_w(lpwhr->lpszPath));
         loop_next = FALSE;
 
         /* If we don't have a path we set it to root */
         if (NULL == lpwhr->lpszPath)
-            lpwhr->lpszPath = WININET_strdup("/");
-        else /* remove \r and \n*/
-        {
-            int nLen = strlen(lpwhr->lpszPath);
-            while ((nLen > 0) && ((lpwhr->lpszPath[nLen-1] == '\r')||(lpwhr->lpszPath[nLen-1] == '\n')))
-                lpwhr->lpszPath[--nLen]='\0';
-        }
-        if(strncmp(lpwhr->lpszPath, "http://", sizeof("http://") -1) != 0
+            lpwhr->lpszPath = WININET_strdupW(szSlash);
+
+        if(CSTR_EQUAL != CompareStringW( LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
+                           lpwhr->lpszPath, strlenW(szHttp), szHttp, strlenW(szHttp) )
            && lpwhr->lpszPath[0] != '/') /* not an absolute path ?? --> fix it !! */
         {
-            char *fixurl = HeapAlloc(GetProcessHeap(), 0, strlen(lpwhr->lpszPath) + 2);
+            WCHAR *fixurl = HeapAlloc(GetProcessHeap(), 0, 
+                                 (strlenW(lpwhr->lpszPath) + 2)*sizeof(WCHAR));
             *fixurl = '/';
-            strcpy(fixurl + 1, lpwhr->lpszPath);
+            strcpyW(fixurl + 1, lpwhr->lpszPath);
             HeapFree( GetProcessHeap(), 0, lpwhr->lpszPath );
             lpwhr->lpszPath = fixurl;
         }
 
         /* Calculate length of request string */
         requestStringLen =
-            strlen(lpwhr->lpszVerb) +
-            strlen(lpwhr->lpszPath) +
-            strlen(HTTPHEADER) +
+            strlenW(lpwhr->lpszVerb) +
+            strlenW(lpwhr->lpszPath) +
+            strlenW(HTTPHEADER) +
             5; /* " \r\n\r\n" */
 
 	/* add "\r\n" to end of lpszHeaders if needed */
 	if (lpszHeaders)
 	{
-	    int len = strlen(lpszHeaders);
+	    int len = strlenW(lpszHeaders);
 
 	    /* Check if the string is terminated with \r\n, but not if
 	     * the string is less that 2 characters long, because then
@@ -1401,23 +1456,24 @@
 	     * the string. Besides, if it is less than 2 characters
 	     * long, then clearly, its not terminated with \r\n.
 	     */
-	    if ((len > 2) && (memcmp(lpszHeaders + (len - 2), "\r\n", 2) == 0))
+	    if ((len > 2) && (memcmp(lpszHeaders + (len - 2), szcrlf, sizeof szcrlf) == 0))
 	    {
-		lpszHeaders_r_n = WININET_strdup(lpszHeaders);
+		lpszHeaders_r_n = WININET_strdupW(lpszHeaders);
 	    }
 	    else
 	    {
 		TRACE("Adding \r\n to lpszHeaders.\n");
-		lpszHeaders_r_n =  HeapAlloc( GetProcessHeap(), 0, strlen(lpszHeaders) + 3 );
-		strcpy( lpszHeaders_r_n, lpszHeaders );
-		strcpy( lpszHeaders_r_n + strlen(lpszHeaders), "\r\n" );
+		lpszHeaders_r_n =  HeapAlloc( GetProcessHeap(), 0, 
+                                             (len + 3)*sizeof(WCHAR) );
+		strcpyW( lpszHeaders_r_n, lpszHeaders );
+		strcatW( lpszHeaders_r_n, szcrlf );
 	    }
 	}
 
         /* Add length of passed headers */
         if (lpszHeaders)
         {
-            headerLength = -1 == dwHeaderLength ?  strlen(lpszHeaders_r_n) : dwHeaderLength;
+            headerLength = -1 == dwHeaderLength ? strlenW(lpszHeaders_r_n) : dwHeaderLength;
             requestStringLen += headerLength +  2; /* \r\n */
         }
 
@@ -1433,8 +1489,8 @@
         {
 	    if (lpwhr->pCustHeaders[i].wFlags & HDR_ISREQUEST)
 	    {
-                requestStringLen += strlen(lpwhr->pCustHeaders[i].lpszField) +
-                    strlen(lpwhr->pCustHeaders[i].lpszValue) + 4; /*: \r\n */
+                requestStringLen += strlenW(lpwhr->pCustHeaders[i].lpszField) +
+                    strlenW(lpwhr->pCustHeaders[i].lpszValue) + 4; /*: \r\n */
 	    }
         }
 
@@ -1443,24 +1499,22 @@
         {
             if (lpwhr->StdHeaders[i].wFlags & HDR_ISREQUEST)
             {
-                requestStringLen += strlen(lpwhr->StdHeaders[i].lpszField) +
-                    strlen(lpwhr->StdHeaders[i].lpszValue) + 4; /*: \r\n */
+                requestStringLen += strlenW(lpwhr->StdHeaders[i].lpszField) +
+                    strlenW(lpwhr->StdHeaders[i].lpszValue) + 4; /*: \r\n */
             }
         }
 
         if (lpwhr->lpszHostName)
-            requestStringLen += (strlen(HTTPHOSTHEADER) + strlen(lpwhr->lpszHostName));
+            requestStringLen += (strlenW(HTTPHOSTHEADER) + strlenW(lpwhr->lpszHostName));
 
         /* if there is optional data to send, add the length */
         if (lpOptional)
         {
             requestStringLen += dwOptionalLength;
-        } else {
-            requestStringLen += 2;
         }
 
         /* Allocate string to hold entire request */
-        requestString = HeapAlloc(GetProcessHeap(), 0, requestStringLen + 1);
+        requestString = HeapAlloc(GetProcessHeap(), 0, (requestStringLen + 1)*sizeof(WCHAR));
         if (NULL == requestString)
         {
             INTERNET_SetLastError(ERROR_OUTOFMEMORY);
@@ -1468,19 +1522,23 @@
         }
 
         /* Build request string */
-        cnt = sprintf(requestString, "%s %s%s",
-                      lpwhr->lpszVerb,
-                      lpwhr->lpszPath,
-                      HTTPHEADER);
+        strcpyW(requestString, lpwhr->lpszVerb);
+        strcatW(requestString, szSpace);
+        strcatW(requestString, lpwhr->lpszPath);
+        strcatW(requestString, HTTPHEADER );
+        cnt = strlenW(requestString);
 
         /* Append standard request headers */
         for (i = 0; i <= HTTP_QUERY_MAX; i++)
         {
             if (lpwhr->StdHeaders[i].wFlags & HDR_ISREQUEST)
             {
-                cnt += sprintf(requestString + cnt, "\r\n%s: %s",
+                WCHAR szFmt[] = { '\r','\n','%','s',':',' ','%','s', 0};
+                cnt += sprintfW(requestString + cnt, szFmt,
                                lpwhr->StdHeaders[i].lpszField, lpwhr->StdHeaders[i].lpszValue);
-                TRACE("Adding header %s (%s)\n",lpwhr->StdHeaders[i].lpszField,lpwhr->StdHeaders[i].lpszValue);
+                TRACE("Adding header %s (%s)\n",
+                       debugstr_w(lpwhr->StdHeaders[i].lpszField),
+                       debugstr_w(lpwhr->StdHeaders[i].lpszValue));
             }
         }
 
@@ -1489,36 +1547,42 @@
         {
             if (lpwhr->pCustHeaders[i].wFlags & HDR_ISREQUEST)
             {
-                cnt += sprintf(requestString + cnt, "\r\n%s: %s",
+                WCHAR szFmt[] = { '\r','\n','%','s',':',' ','%','s', 0};
+                cnt += sprintfW(requestString + cnt, szFmt,
                                lpwhr->pCustHeaders[i].lpszField, lpwhr->pCustHeaders[i].lpszValue);
-                TRACE("Adding custom header %s (%s)\n",lpwhr->pCustHeaders[i].lpszField,lpwhr->pCustHeaders[i].lpszValue);
+                TRACE("Adding custom header %s (%s)\n",
+                       debugstr_w(lpwhr->pCustHeaders[i].lpszField),
+                       debugstr_w(lpwhr->pCustHeaders[i].lpszValue));
             }
         }
 
         if (lpwhr->lpszHostName)
-            cnt += sprintf(requestString + cnt, "%s%s", HTTPHOSTHEADER, lpwhr->lpszHostName);
+        {
+            WCHAR szFmt[] = { '%','s','%','s',0 };
+            cnt += sprintfW(requestString + cnt, szFmt, HTTPHOSTHEADER, lpwhr->lpszHostName);
+        }
 
         /* Append passed request headers */
         if (lpszHeaders_r_n)
         {
-            strcpy(requestString + cnt, "\r\n");
+            strcpyW(requestString + cnt, szcrlf);
             cnt += 2;
-            strcpy(requestString + cnt, lpszHeaders_r_n);
+            strcpyW(requestString + cnt, lpszHeaders_r_n);
             cnt += headerLength;
 	    /* only add \r\n if not already present */
-	    if (memcmp((requestString + cnt) - 2, "\r\n", 2) != 0)
+	    if (memcmp((requestString + cnt) - 2, szcrlf, sizeof szcrlf) != 0)
 	    {
-                strcpy(requestString + cnt, "\r\n");
+                strcpyW(requestString + cnt, szcrlf);
                 cnt += 2;
 	    }
         }
 
         /* Set (header) termination string for request */
-        if (memcmp((requestString + cnt) - 4, "\r\n\r\n", 4) != 0)
+        if (memcmp((requestString + cnt) - 4, sztwocrlf, sizeof sztwocrlf) != 0)
         { /* only add it if the request string doesn't already
              have the thing.. (could happen if the custom header
              added it */
-                strcpy(requestString + cnt, "\r\n");
+                strcpyW(requestString + cnt, szcrlf);
                 cnt += 2;
         }
         else
@@ -1527,7 +1591,7 @@
         /* if optional data, append it */
         if (lpOptional)
         {
-            memcpy(requestString + cnt, lpOptional, dwOptionalLength);
+            memcpy(requestString + cnt, lpOptional, dwOptionalLength*sizeof(WCHAR));
             cnt += dwOptionalLength;
             /* we also have to decrease the expected string length by two,
              * since we won't be adding on those following \r\n's */
@@ -1536,11 +1600,11 @@
         else
         { /* if there is no optional data, add on another \r\n just to be safe */
                 /* termination for request */
-                strcpy(requestString + cnt, "\r\n");
+                strcpyW(requestString + cnt, szcrlf);
                 cnt += 2;
         }
 
-        TRACE("(%s) len(%d)\n", requestString, requestStringLen);
+        TRACE("(%s) len(%d)\n", debugstr_w(requestString), requestStringLen);
         /* Send the request and store the results */
         if (!HTTP_OpenConnection(lpwhr))
             goto lend;
@@ -1548,8 +1612,19 @@
         SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
                           INTERNET_STATUS_SENDING_REQUEST, NULL, 0);
 
-        NETCON_send(&lpwhr->netConnection, requestString, requestStringLen,
-                    0, &cnt);
+        /* send the request as ASCII */
+        {
+            int ascii_len;
+            char *ascii_req;
+
+            ascii_len = WideCharToMultiByte( CP_ACP, 0, requestString,
+                            requestStringLen, NULL, 0, NULL, NULL );
+            ascii_req = HeapAlloc( GetProcessHeap(), 0, ascii_len );
+            WideCharToMultiByte( CP_ACP, 0, requestString, requestStringLen,
+                            ascii_req, ascii_len, NULL, NULL );
+            NETCON_send(&lpwhr->netConnection, ascii_req, ascii_len, 0, &cnt);
+            HeapFree( GetProcessHeap(), 0, ascii_req );
+        }
 
 
         SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
@@ -1571,19 +1646,20 @@
                           sizeof(DWORD));
 
         /* process headers here. Is this right? */
-        CustHeaderIndex = HTTP_GetCustomHeaderIndex(lpwhr, "Set-Cookie");
+        CustHeaderIndex = HTTP_GetCustomHeaderIndex(lpwhr, szSetCookie);
         if (CustHeaderIndex >= 0)
         {
-            LPHTTPHEADERA setCookieHeader;
-            int nPosStart = 0, nPosEnd = 0;
+            LPHTTPHEADERW setCookieHeader;
+            int nPosStart = 0, nPosEnd = 0, len;
+            WCHAR szFmt[] = { 'h','t','t','p',':','/','/','%','s','/',0};
 
             setCookieHeader = &lpwhr->pCustHeaders[CustHeaderIndex];
 
             while (setCookieHeader->lpszValue[nPosEnd] != '\0')
             {
-                LPSTR buf_cookie, cookie_name, cookie_data;
-                LPSTR buf_url;
-                LPSTR domain = NULL;
+                LPWSTR buf_cookie, cookie_name, cookie_data;
+                LPWSTR buf_url;
+                LPWSTR domain = NULL;
                 int nEqualPos = 0;
                 while (setCookieHeader->lpszValue[nPosEnd] != ';' && setCookieHeader->lpszValue[nPosEnd] != ',' &&
                        setCookieHeader->lpszValue[nPosEnd] != '\0')
@@ -1595,7 +1671,8 @@
                     /* fixme: not case sensitive, strcasestr is gnu only */
                     int nDomainPosEnd = 0;
                     int nDomainPosStart = 0, nDomainLength = 0;
-                    LPSTR lpszDomain = strstr(&setCookieHeader->lpszValue[nPosEnd], "domain=");
+                    WCHAR szDomain[] = {'d','o','m','a','i','n','=',0};
+                    LPWSTR lpszDomain = strstrW(&setCookieHeader->lpszValue[nPosEnd], szDomain);
                     if (lpszDomain)
                     { /* they have specified their own domain, lets use it */
                         while (lpszDomain[nDomainPosEnd] != ';' && lpszDomain[nDomainPosEnd] != ',' &&
@@ -1603,18 +1680,18 @@
                         {
                             nDomainPosEnd++;
                         }
-                        nDomainPosStart = strlen("domain=");
+                        nDomainPosStart = strlenW(szDomain);
                         nDomainLength = (nDomainPosEnd - nDomainPosStart) + 1;
-                        domain = HeapAlloc(GetProcessHeap(), 0, nDomainLength + 1);
-                        strncpy(domain, &lpszDomain[nDomainPosStart], nDomainLength);
+                        domain = HeapAlloc(GetProcessHeap(), 0, (nDomainLength + 1)*sizeof(WCHAR));
+                        strncpyW(domain, &lpszDomain[nDomainPosStart], nDomainLength);
                         domain[nDomainLength] = '\0';
                     }
                 }
                 if (setCookieHeader->lpszValue[nPosEnd] == '\0') break;
-                buf_cookie = HeapAlloc(GetProcessHeap(), 0, (nPosEnd - nPosStart) + 1);
-                strncpy(buf_cookie, &setCookieHeader->lpszValue[nPosStart], (nPosEnd - nPosStart));
+                buf_cookie = HeapAlloc(GetProcessHeap(), 0, ((nPosEnd - nPosStart) + 1)*sizeof(WCHAR));
+                strncpyW(buf_cookie, &setCookieHeader->lpszValue[nPosStart], (nPosEnd - nPosStart));
                 buf_cookie[(nPosEnd - nPosStart)] = '\0';
-                TRACE("%s\n", buf_cookie);
+                TRACE("%s\n", debugstr_w(buf_cookie));
                 while (buf_cookie[nEqualPos] != '=' && buf_cookie[nEqualPos] != '\0')
                 {
                     nEqualPos++;
@@ -1625,15 +1702,16 @@
                     break;
                 }
 
-                cookie_name = HeapAlloc(GetProcessHeap(), 0, nEqualPos + 1);
-                strncpy(cookie_name, buf_cookie, nEqualPos);
+                cookie_name = HeapAlloc(GetProcessHeap(), 0, (nEqualPos + 1)*sizeof(WCHAR));
+                strncpyW(cookie_name, buf_cookie, nEqualPos);
                 cookie_name[nEqualPos] = '\0';
                 cookie_data = &buf_cookie[nEqualPos + 1];
 
 
-                buf_url = HeapAlloc(GetProcessHeap(), 0, strlen((domain ? domain : lpwhr->lpszHostName)) + strlen(lpwhr->lpszPath) + 9);
-                sprintf(buf_url, "http://%s/", (domain ? domain : lpwhr->lpszHostName)); /* FIXME PATH!!! */
-                InternetSetCookieA(buf_url, cookie_name, cookie_data);
+                len = strlenW((domain ? domain : lpwhr->lpszHostName)) + strlenW(lpwhr->lpszPath) + 9;
+                buf_url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+                sprintfW(buf_url, szFmt, (domain ? domain : lpwhr->lpszHostName)); /* FIXME PATH!!! */
+                InternetSetCookieW(buf_url, cookie_name, cookie_data);
 
                 HeapFree(GetProcessHeap(), 0, buf_url);
                 HeapFree(GetProcessHeap(), 0, buf_cookie);
@@ -1658,13 +1736,13 @@
     if(!(hIC->hdr.dwFlags & INTERNET_FLAG_NO_AUTO_REDIRECT) && bSuccess)
     {
         DWORD dwCode,dwCodeLength=sizeof(DWORD),dwIndex=0;
-        if(HttpQueryInfoA(hHttpRequest,HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_STATUS_CODE,&dwCode,&dwCodeLength,&dwIndex) &&
+        if(HttpQueryInfoW(hHttpRequest,HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_STATUS_CODE,&dwCode,&dwCodeLength,&dwIndex) &&
             (dwCode==302 || dwCode==301))
         {
-            char szNewLocation[2048];
+            WCHAR szNewLocation[2048];
             DWORD dwBufferSize=2048;
             dwIndex=0;
-            if(HttpQueryInfoA(hHttpRequest,HTTP_QUERY_LOCATION,szNewLocation,&dwBufferSize,&dwIndex))
+            if(HttpQueryInfoW(hHttpRequest,HTTP_QUERY_LOCATION,szNewLocation,&dwBufferSize,&dwIndex))
             {
                 SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
                       INTERNET_STATUS_REDIRECT, szNewLocation,
@@ -1702,13 +1780,13 @@
  *   NULL on failure
  *
  */
-HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
-	INTERNET_PORT nServerPort, LPCSTR lpszUserName,
-	LPCSTR lpszPassword, DWORD dwFlags, DWORD dwContext)
+HINTERNET HTTP_Connect(HINTERNET hInternet, LPCWSTR lpszServerName,
+	INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
+	LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext)
 {
     BOOL bSuccess = FALSE;
     LPWININETAPPINFOW hIC = NULL;
-    LPWININETHTTPSESSIONA lpwhs = NULL;
+    LPWININETHTTPSESSIONW lpwhs = NULL;
     HINTERNET handle = NULL;
 
     TRACE("-->\n");
@@ -1719,7 +1797,7 @@
 
     hIC->hdr.dwContext = dwContext;
     
-    lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONA));
+    lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONW));
     if (NULL == lpwhs)
     {
         INTERNET_SetLastError(ERROR_OUTOFMEMORY);
@@ -1752,9 +1830,9 @@
             FIXME("Proxy bypass is ignored.\n");
     }
     if (NULL != lpszServerName)
-        lpwhs->lpszServerName = WININET_strdup(lpszServerName);
+        lpwhs->lpszServerName = WININET_strdupW(lpszServerName);
     if (NULL != lpszUserName)
-        lpwhs->lpszUserName = WININET_strdup(lpszUserName);
+        lpwhs->lpszUserName = WININET_strdupW(lpszUserName);
     lpwhs->nServerPort = nServerPort;
 
     if (hIC->lpfnStatusCB)
@@ -1799,10 +1877,10 @@
  *   TRUE  on success
  *   FALSE on failure
  */
-BOOL HTTP_OpenConnection(LPWININETHTTPREQA lpwhr)
+BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr)
 {
     BOOL bSuccess = FALSE;
-    LPWININETHTTPSESSIONA lpwhs;
+    LPWININETHTTPSESSIONW lpwhs;
     LPWININETAPPINFOW hIC = NULL;
 
     TRACE("-->\n");
@@ -1814,7 +1892,7 @@
         goto lend;
     }
 
-    lpwhs = (LPWININETHTTPSESSIONA)lpwhr->hdr.lpwhparent;
+    lpwhs = (LPWININETHTTPSESSIONW)lpwhr->hdr.lpwhparent;
 
     hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
     SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
@@ -1859,14 +1937,17 @@
  *   TRUE  on success
  *   FALSE on error
  */
-BOOL HTTP_GetResponseHeaders(LPWININETHTTPREQA lpwhr)
+BOOL HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr)
 {
     INT cbreaks = 0;
-    CHAR buffer[MAX_REPLY_LEN];
+    WCHAR buffer[MAX_REPLY_LEN];
     DWORD buflen = MAX_REPLY_LEN;
     BOOL bSuccess = FALSE;
     INT  rc = 0;
-    CHAR value[MAX_FIELD_VALUE_LEN], field[MAX_FIELD_LEN];
+    WCHAR value[MAX_FIELD_VALUE_LEN], field[MAX_FIELD_LEN];
+    WCHAR szStatus[] = {'S','t','a','t','u','s',0};
+    WCHAR szHttp[] = { 'H','T','T','P',0 };
+    char bufferA[MAX_REPLY_LEN];
 
     TRACE("-->\n");
 
@@ -1883,22 +1964,24 @@
      */
     buflen = MAX_REPLY_LEN;
     memset(buffer, 0, MAX_REPLY_LEN);
-    if (!NETCON_getNextLine(&lpwhr->netConnection, buffer, &buflen))
+    if (!NETCON_getNextLine(&lpwhr->netConnection, bufferA, &buflen))
         goto lend;
+    MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
 
-    if (strncmp(buffer, "HTTP", 4) != 0)
+    if (strncmpW(buffer, szHttp, 4) != 0)
         goto lend;
 
     buffer[12]='\0';
-    HTTP_ProcessHeader(lpwhr, "Status", buffer+9, (HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE));
+    HTTP_ProcessHeader(lpwhr, szStatus, buffer+9, (HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE));
 
     /* Parse each response line */
     do
     {
 	buflen = MAX_REPLY_LEN;
-        if (NETCON_getNextLine(&lpwhr->netConnection, buffer, &buflen))
+        if (NETCON_getNextLine(&lpwhr->netConnection, bufferA, &buflen))
 	{
-            TRACE("got line %s, now interpretting\n", debugstr_a(buffer));
+            TRACE("got line %s, now interpretting\n", debugstr_a(bufferA));
+            MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
             if (!HTTP_InterpretHttpHeader(buffer, field, MAX_FIELD_LEN, value, MAX_FIELD_VALUE_LEN))
                 break;
 
@@ -1934,9 +2017,9 @@
  *   TRUE  on success
  *   FALSE on error
  */
-INT stripSpaces(LPCSTR lpszSrc, LPSTR lpszStart, INT *len)
+INT stripSpaces(LPCWSTR lpszSrc, LPWSTR lpszStart, INT *len)
 {
-    LPCSTR lpsztmp;
+    LPCWSTR lpsztmp;
     INT srclen;
 
     srclen = 0;
@@ -1954,16 +2037,16 @@
     }
 
     *len = min(*len, srclen);
-    strncpy(lpszStart, lpszSrc, *len);
+    strncpyW(lpszStart, lpszSrc, *len);
     lpszStart[*len] = '\0';
 
     return *len;
 }
 
 
-BOOL HTTP_InterpretHttpHeader(LPSTR buffer, LPSTR field, INT fieldlen, LPSTR value, INT valuelen)
+BOOL HTTP_InterpretHttpHeader(LPWSTR buffer, LPWSTR field, INT fieldlen, LPWSTR value, INT valuelen)
 {
-    CHAR *pd;
+    WCHAR *pd;
     BOOL bSuccess = FALSE;
 
     TRACE("\n");
@@ -1971,7 +2054,7 @@
     *field = '\0';
     *value = '\0';
 
-    pd = strchr(buffer, ':');
+    pd = strchrW(buffer, ':');
     if (pd)
     {
 	*pd = '\0';
@@ -1982,7 +2065,7 @@
 	}
     }
 
-    TRACE("%d: field(%s) Value(%s)\n", bSuccess, field, value);
+    TRACE("%d: field(%s) Value(%s)\n", bSuccess, debugstr_w(field), debugstr_w(value));
     return bSuccess;
 }
 
@@ -1994,53 +2077,79 @@
  *
  * FIXME: This should be stuffed into a hash table
  */
-INT HTTP_GetStdHeaderIndex(LPCSTR lpszField)
+INT HTTP_GetStdHeaderIndex(LPCWSTR lpszField)
 {
     INT index = -1;
+    WCHAR szContentLength[] = {
+       'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0};
+    WCHAR szStatus[] = {'S','t','a','t','u','s',0};
+    WCHAR szContentType[] = {
+       'C','o','n','t','e','n','t','-','T','y','p','e',0};
+    WCHAR szLastModified[] = {
+       'L','a','s','t','-','M','o','d','i','f','i','e','d',0};
+    WCHAR szLocation[] = {'L','o','c','a','t','i','o','n',0};
+    WCHAR szAccept[] = {'A','c','c','e','p','t',0};
+    WCHAR szReferer[] = { 'R','e','f','e','r','e','r',0};
+    WCHAR szContentTrans[] = { 'C','o','n','t','e','n','t','-',
+       'T','r','a','n','s','f','e','r','-','E','n','c','o','d','i','n','g',0};
+    WCHAR szDate[] = { 'D','a','t','e',0};
+    WCHAR szServer[] = { 'S','e','r','v','e','r',0};
+    WCHAR szConnection[] = { 'C','o','n','n','e','c','t','i','o','n',0};
+    WCHAR szETag[] = { 'E','T','a','g',0};
+    WCHAR szAcceptRanges[] = {
+       'A','c','c','e','p','t','-','R','a','n','g','e','s',0 };
+    WCHAR szExpires[] = { 'E','x','p','i','r','e','s',0 };
+    WCHAR szMimeVersion[] = {
+       'M','i','m','e','-','V','e','r','s','i','o','n', 0};
+    WCHAR szPragma[] = { 'P','r','a','g','m','a', 0};
+    WCHAR szCacheControl[] = {
+       'C','a','c','h','e','-','C','o','n','t','r','o','l',0};
+    WCHAR szUserAgent[] = { 'U','s','e','r','-','A','g','e','n','t',0};
+    WCHAR szProxyAuth[] = {
+       'P','r','o','x','y','-',
+       'A','u','t','h','e','n','t','i','c','a','t','e', 0};
 
-    if (!strcasecmp(lpszField, "Content-Length"))
+    if (!strcmpiW(lpszField, szContentLength))
         index = HTTP_QUERY_CONTENT_LENGTH;
-    else if (!strcasecmp(lpszField,"Status"))
+    else if (!strcmpiW(lpszField,szStatus))
         index = HTTP_QUERY_STATUS_CODE;
-    else if (!strcasecmp(lpszField,"Content-Type"))
+    else if (!strcmpiW(lpszField,szContentType))
         index = HTTP_QUERY_CONTENT_TYPE;
-    else if (!strcasecmp(lpszField,"Last-Modified"))
+    else if (!strcmpiW(lpszField,szLastModified))
         index = HTTP_QUERY_LAST_MODIFIED;
-    else if (!strcasecmp(lpszField,"Location"))
+    else if (!strcmpiW(lpszField,szLocation))
         index = HTTP_QUERY_LOCATION;
-    else if (!strcasecmp(lpszField,"Accept"))
+    else if (!strcmpiW(lpszField,szAccept))
         index = HTTP_QUERY_ACCEPT;
-    else if (!strcasecmp(lpszField,"Referer"))
+    else if (!strcmpiW(lpszField,szReferer))
         index = HTTP_QUERY_REFERER;
-    else if (!strcasecmp(lpszField,"Content-Transfer-Encoding"))
+    else if (!strcmpiW(lpszField,szContentTrans))
         index = HTTP_QUERY_CONTENT_TRANSFER_ENCODING;
-    else if (!strcasecmp(lpszField,"Date"))
+    else if (!strcmpiW(lpszField,szDate))
         index = HTTP_QUERY_DATE;
-    else if (!strcasecmp(lpszField,"Server"))
+    else if (!strcmpiW(lpszField,szServer))
         index = HTTP_QUERY_SERVER;
-    else if (!strcasecmp(lpszField,"Connection"))
+    else if (!strcmpiW(lpszField,szConnection))
         index = HTTP_QUERY_CONNECTION;
-    else if (!strcasecmp(lpszField,"ETag"))
+    else if (!strcmpiW(lpszField,szETag))
         index = HTTP_QUERY_ETAG;
-    else if (!strcasecmp(lpszField,"Accept-Ranges"))
+    else if (!strcmpiW(lpszField,szAcceptRanges))
         index = HTTP_QUERY_ACCEPT_RANGES;
-    else if (!strcasecmp(lpszField,"Expires"))
+    else if (!strcmpiW(lpszField,szExpires))
         index = HTTP_QUERY_EXPIRES;
-    else if (!strcasecmp(lpszField,"Mime-Version"))
+    else if (!strcmpiW(lpszField,szMimeVersion))
         index = HTTP_QUERY_MIME_VERSION;
-    else if (!strcasecmp(lpszField,"Pragma"))
+    else if (!strcmpiW(lpszField,szPragma))
         index = HTTP_QUERY_PRAGMA;
-    else if (!strcasecmp(lpszField,"Cache-Control"))
+    else if (!strcmpiW(lpszField,szCacheControl))
         index = HTTP_QUERY_CACHE_CONTROL;
-    else if (!strcasecmp(lpszField,"Content-Length"))
-        index = HTTP_QUERY_CONTENT_LENGTH;
-    else if (!strcasecmp(lpszField,"User-Agent"))
+    else if (!strcmpiW(lpszField,szUserAgent))
         index = HTTP_QUERY_USER_AGENT;
-    else if (!strcasecmp(lpszField,"Proxy-Authenticate"))
+    else if (!strcmpiW(lpszField,szProxyAuth))
         index = HTTP_QUERY_PROXY_AUTHENTICATE;
     else
     {
-       TRACE("Couldn't find %s in standard header table\n", lpszField);
+        TRACE("Couldn't find %s in standard header table\n", debugstr_w(lpszField));
     }
 
     return index;
@@ -2056,13 +2165,13 @@
 
 #define COALESCEFLASG (HTTP_ADDHDR_FLAG_COALESCE|HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA|HTTP_ADDHDR_FLAG_COALESCE_WITH_SEMICOLON)
 
-BOOL HTTP_ProcessHeader(LPWININETHTTPREQA lpwhr, LPCSTR field, LPCSTR value, DWORD dwModifier)
+BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR value, DWORD dwModifier)
 {
-    LPHTTPHEADERA lphttpHdr = NULL;
+    LPHTTPHEADERW lphttpHdr = NULL;
     BOOL bSuccess = FALSE;
     INT index;
 
-    TRACE("--> %s: %s - 0x%08x\n", field, value, (unsigned int)dwModifier);
+    TRACE("--> %s: %s - 0x%08x\n", debugstr_w(field), debugstr_w(value), (unsigned int)dwModifier);
 
     /* Adjust modifier flags */
     if (dwModifier & COALESCEFLASG)
@@ -2087,10 +2196,10 @@
         }
         else
         {
-            HTTPHEADERA hdr;
+            HTTPHEADERW hdr;
 
-            hdr.lpszField = (LPSTR)field;
-            hdr.lpszValue = (LPSTR)value;
+            hdr.lpszField = (LPWSTR)field;
+            hdr.lpszValue = (LPWSTR)value;
             hdr.wFlags = hdr.wCount = 0;
 
             if (dwModifier & HTTP_ADDHDR_FLAG_REQ)
@@ -2111,17 +2220,17 @@
 
         if (!lpwhr->StdHeaders[index].lpszField)
         {
-            lphttpHdr->lpszField = WININET_strdup(field);
+            lphttpHdr->lpszField = WININET_strdupW(field);
 
             if (dwModifier & HTTP_ADDHDR_FLAG_REQ)
                 lphttpHdr->wFlags |= HDR_ISREQUEST;
         }
 
-        slen = strlen(value) + 1;
-        lphttpHdr->lpszValue = HeapAlloc(GetProcessHeap(), 0, slen);
+        slen = strlenW(value) + 1;
+        lphttpHdr->lpszValue = HeapAlloc(GetProcessHeap(), 0, slen*sizeof(WCHAR));
         if (lphttpHdr->lpszValue)
         {
-            memcpy(lphttpHdr->lpszValue, value, slen);
+            strcpyW(lphttpHdr->lpszValue, value);
             bSuccess = TRUE;
         }
         else
@@ -2133,10 +2242,10 @@
     {
         if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE)
         {
-            LPSTR lpsztmp;
+            LPWSTR lpsztmp;
             INT len;
 
-            len = strlen(value);
+            len = strlenW(value);
 
             if (len <= 0)
             {
@@ -2147,11 +2256,11 @@
             }
             else
             {
-                lpsztmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,  lphttpHdr->lpszValue, len+1);
+                lpsztmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,  lphttpHdr->lpszValue, (len+1)*sizeof(WCHAR));
                 if (lpsztmp)
                 {
                     lphttpHdr->lpszValue = lpsztmp;
-                    strcpy(lpsztmp, value);
+                    strcpyW(lpsztmp, value);
                     bSuccess = TRUE;
                 }
                 else
@@ -2163,11 +2272,11 @@
         }
         else if (dwModifier & COALESCEFLASG)
         {
-            LPSTR lpsztmp;
-            CHAR ch = 0;
+            LPWSTR lpsztmp;
+            WCHAR ch = 0;
             INT len = 0;
-            INT origlen = strlen(lphttpHdr->lpszValue);
-            INT valuelen = strlen(value);
+            INT origlen = strlenW(lphttpHdr->lpszValue);
+            INT valuelen = strlenW(value);
 
             if (dwModifier & HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA)
             {
@@ -2182,10 +2291,9 @@
 
             len = origlen + valuelen + ((ch > 0) ? 1 : 0);
 
-            lpsztmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,  lphttpHdr->lpszValue, len+1);
+            lpsztmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,  lphttpHdr->lpszValue, (len+1)*sizeof(WCHAR));
             if (lpsztmp)
             {
-		lphttpHdr->lpszValue = lpsztmp;
 		/* FIXME: Increment lphttpHdr->wCount. Perhaps lpszValue should be an array */
                 if (ch > 0)
                 {
@@ -2193,7 +2301,7 @@
                     origlen++;
                 }
 
-                memcpy(&lphttpHdr->lpszValue[origlen], value, valuelen);
+                memcpy(&lphttpHdr->lpszValue[origlen], value, valuelen*sizeof(WCHAR));
                 lphttpHdr->lpszValue[len] = '\0';
                 bSuccess = TRUE;
             }
@@ -2215,18 +2323,18 @@
  * Close socket connection
  *
  */
-VOID HTTP_CloseConnection(LPWININETHTTPREQA lpwhr)
+VOID HTTP_CloseConnection(LPWININETHTTPREQW lpwhr)
 {
 
 
-    LPWININETHTTPSESSIONA lpwhs = NULL;
+    LPWININETHTTPSESSIONW lpwhs = NULL;
     LPWININETAPPINFOW hIC = NULL;
     HINTERNET handle;
 
     TRACE("%p\n",lpwhr);
 
     handle = WININET_FindHandle( &lpwhr->hdr );
-    lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
+    lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
     hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
 
     SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
@@ -2248,10 +2356,10 @@
  * Deallocate request handle
  *
  */
-void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr)
+void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQW lpwhr)
 {
     int i;
-    LPWININETHTTPSESSIONA lpwhs = NULL;
+    LPWININETHTTPSESSIONW lpwhs = NULL;
     LPWININETAPPINFOW hIC = NULL;
     HINTERNET handle;
 
@@ -2261,7 +2369,7 @@
         HTTP_CloseConnection(lpwhr);
 
     handle = WININET_FindHandle( &lpwhr->hdr );
-    lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
+    lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
     hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
 
     SendAsyncCallback(hIC, handle, lpwhr->hdr.dwContext,
@@ -2302,7 +2410,7 @@
  * Deallocate session handle
  *
  */
-void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs)
+void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONW lpwhs)
 {
     LPWININETAPPINFOW hIC = NULL;
     HINTERNET handle;
@@ -2330,15 +2438,15 @@
  * Return index of custom header from header array
  *
  */
-INT HTTP_GetCustomHeaderIndex(LPWININETHTTPREQA lpwhr, LPCSTR lpszField)
+INT HTTP_GetCustomHeaderIndex(LPWININETHTTPREQW lpwhr, LPCWSTR lpszField)
 {
     INT index;
 
-    TRACE("%s\n", lpszField);
+    TRACE("%s\n", debugstr_w(lpszField));
 
     for (index = 0; index < lpwhr->nCustHeaders; index++)
     {
-	if (!strcasecmp(lpwhr->pCustHeaders[index].lpszField, lpszField))
+	if (!strcmpiW(lpwhr->pCustHeaders[index].lpszField, lpszField))
 	    break;
 
     }
@@ -2357,24 +2465,24 @@
  * Insert header into array
  *
  */
-BOOL HTTP_InsertCustomHeader(LPWININETHTTPREQA lpwhr, LPHTTPHEADERA lpHdr)
+BOOL HTTP_InsertCustomHeader(LPWININETHTTPREQW lpwhr, LPHTTPHEADERW lpHdr)
 {
     INT count;
-    LPHTTPHEADERA lph = NULL;
+    LPHTTPHEADERW lph = NULL;
     BOOL r = FALSE;
 
-    TRACE("--> %s: %s\n", lpHdr->lpszField, lpHdr->lpszValue);
+    TRACE("--> %s: %s\n", debugstr_w(lpHdr->lpszField), debugstr_w(lpHdr->lpszValue));
     count = lpwhr->nCustHeaders + 1;
     if (count > 1)
-	lph = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpwhr->pCustHeaders, sizeof(HTTPHEADERA) * count);
+	lph = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpwhr->pCustHeaders, sizeof(HTTPHEADERW) * count);
     else
-	lph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HTTPHEADERA) * count);
+	lph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HTTPHEADERW) * count);
 
     if (NULL != lph)
     {
 	lpwhr->pCustHeaders = lph;
-        lpwhr->pCustHeaders[count-1].lpszField = WININET_strdup(lpHdr->lpszField);
-        lpwhr->pCustHeaders[count-1].lpszValue = WININET_strdup(lpHdr->lpszValue);
+        lpwhr->pCustHeaders[count-1].lpszField = WININET_strdupW(lpHdr->lpszField);
+        lpwhr->pCustHeaders[count-1].lpszValue = WININET_strdupW(lpHdr->lpszValue);
         lpwhr->pCustHeaders[count-1].wFlags = lpHdr->wFlags;
         lpwhr->pCustHeaders[count-1].wCount= lpHdr->wCount;
 	lpwhr->nCustHeaders++;
@@ -2395,7 +2503,7 @@
  * Delete header from array
  *  If this function is called, the indexs may change.
  */
-BOOL HTTP_DeleteCustomHeader(LPWININETHTTPREQA lpwhr, INT index)
+BOOL HTTP_DeleteCustomHeader(LPWININETHTTPREQW lpwhr, INT index)
 {
     if( lpwhr->nCustHeaders <= 0 )
         return FALSE;
@@ -2404,8 +2512,8 @@
     lpwhr->nCustHeaders--;
 
     memmove( &lpwhr->pCustHeaders[index], &lpwhr->pCustHeaders[index+1],
-             (lpwhr->nCustHeaders - index)* sizeof(HTTPHEADERA) );
-    memset( &lpwhr->pCustHeaders[lpwhr->nCustHeaders], 0, sizeof(HTTPHEADERA) );
+             (lpwhr->nCustHeaders - index)* sizeof(HTTPHEADERW) );
+    memset( &lpwhr->pCustHeaders[lpwhr->nCustHeaders], 0, sizeof(HTTPHEADERW) );
 
     return TRUE;
 }
Index: dlls/wininet/internet.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/internet.c,v
retrieving revision 1.79
diff -u -r1.79 internet.c
--- dlls/wininet/internet.c	25 Mar 2004 05:29:47 -0000	1.79
+++ dlls/wininet/internet.c	28 Mar 2004 05:33:00 -0000
@@ -82,8 +82,8 @@
 } WITHREADERROR, *LPWITHREADERROR;
 
 BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData);
-HINTERNET WINAPI INTERNET_InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
-					   LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext);
+HINTERNET WINAPI INTERNET_InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
+					   LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext);
 VOID INTERNET_ExecuteWork();
 
 DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
@@ -647,15 +647,15 @@
  *    NULL on failure
  *
  */
-HINTERNET WINAPI InternetConnectA(HINTERNET hInternet,
-    LPCSTR lpszServerName, INTERNET_PORT nServerPort,
-    LPCSTR lpszUserName, LPCSTR lpszPassword,
+HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
+    LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
+    LPCWSTR lpszUserName, LPCWSTR lpszPassword,
     DWORD dwService, DWORD dwFlags, DWORD dwContext)
 {
     HINTERNET rc = (HINTERNET) NULL;
 
-    TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet, debugstr_a(lpszServerName),
-	  nServerPort, debugstr_a(lpszUserName), debugstr_a(lpszPassword),
+    TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet, debugstr_w(lpszServerName),
+	  nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword),
 	  dwService, dwFlags, dwContext);
 
     /* Clear any error information */
@@ -684,7 +684,7 @@
 
 
 /***********************************************************************
- *           InternetConnectW (WININET.@)
+ *           InternetConnectA (WININET.@)
  *
  * Open a ftp, gopher or http session
  *
@@ -693,46 +693,38 @@
  *    NULL on failure
  *
  */
-HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
-    LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
-    LPCWSTR lpszUserName, LPCWSTR lpszPassword,
+HINTERNET WINAPI InternetConnectA(HINTERNET hInternet,
+    LPCSTR lpszServerName, INTERNET_PORT nServerPort,
+    LPCSTR lpszUserName, LPCSTR lpszPassword,
     DWORD dwService, DWORD dwFlags, DWORD dwContext)
 {
     HINTERNET rc = (HINTERNET)NULL;
-    INT lenServer = 0;
-    INT lenUser = 0;
-    INT lenPass = 0;
-    CHAR *szServerName = NULL;
-    CHAR *szUserName = NULL;
-    CHAR *szPassword = NULL;
+    INT len = 0;
+    LPWSTR szServerName = NULL;
+    LPWSTR szUserName = NULL;
+    LPWSTR szPassword = NULL;
 
     if (lpszServerName)
     {
-	lenServer = WideCharToMultiByte(CP_ACP, 0, lpszServerName, -1, NULL, 0,
-                            NULL, NULL);
-        szServerName = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenServer*sizeof(CHAR));
-        WideCharToMultiByte(CP_ACP, 0, lpszServerName, -1, szServerName, lenServer,
-                            NULL, NULL);
+	len = MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, NULL, 0);
+        szServerName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+        MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, szServerName, len);
     }
     if (lpszUserName)
     {
-	lenUser = WideCharToMultiByte(CP_ACP, 0, lpszUserName, -1, NULL, 0,
-                            NULL, NULL);
-        szUserName = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenUser*sizeof(CHAR));
-        WideCharToMultiByte(CP_ACP, 0, lpszUserName, -1, szUserName, lenUser,
-                            NULL, NULL);
+	len = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
+        szUserName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+        MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, szUserName, len);
     }
     if (lpszPassword)
     {
-	lenPass = WideCharToMultiByte(CP_ACP, 0, lpszPassword, -1, NULL, 0,
-                            NULL, NULL);
-        szPassword = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenPass*sizeof(CHAR));
-        WideCharToMultiByte(CP_ACP, 0, lpszPassword, -1, szPassword, lenPass,
-                            NULL, NULL);
+	len = MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, NULL, 0);
+        szPassword = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+        MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, szPassword, len);
     }
 
 
-    rc = InternetConnectA(hInternet, szServerName, nServerPort,
+    rc = InternetConnectW(hInternet, szServerName, nServerPort,
         szUserName, szPassword, dwService, dwFlags, dwContext);
 
     if (szServerName) HeapFree(GetProcessHeap(), 0, szServerName);
@@ -931,12 +923,12 @@
 		break;
 
 	    case WH_HHTTPSESSION:
-		HTTP_CloseHTTPSessionHandle((LPWININETHTTPSESSIONA) lpwh);
+		HTTP_CloseHTTPSessionHandle((LPWININETHTTPSESSIONW) lpwh);
 		retval = TRUE;
 		break;
 
 	    case WH_HHTTPREQ:
-		HTTP_CloseHTTPRequestHandle((LPWININETHTTPREQA) lpwh);
+		HTTP_CloseHTTPRequestHandle((LPWININETHTTPREQW) lpwh);
 		retval = TRUE;
 		break;
 
@@ -1519,7 +1511,7 @@
             FIXME("This shouldn't be here! We don't support this kind"
                   " of connection anymore. Must use NETCON functions,"
                   " especially if using SSL\n");
-            nSocket = ((LPWININETHTTPREQA)lpwh)->netConnection.socketFD;
+            nSocket = ((LPWININETHTTPREQW)lpwh)->netConnection.socketFD;
             break;
 
         case WH_HFILE:
@@ -1568,7 +1560,7 @@
     switch (lpwh->htype)
     {
         case WH_HHTTPREQ:
-            if (!NETCON_recv(&((LPWININETHTTPREQA)lpwh)->netConnection, lpBuffer,
+            if (!NETCON_recv(&((LPWININETHTTPREQW)lpwh)->netConnection, lpBuffer,
                              dwNumOfBytesToRead, 0, (int *)dwNumOfBytesRead))
             {
                 *dwNumOfBytesRead = 0;
@@ -1686,23 +1678,24 @@
             ULONG type = lpwhh->htype;
             if (type == WH_HHTTPREQ)
             {
-                LPWININETHTTPREQA lpreq = (LPWININETHTTPREQA) lpwhh;
-                char url[1023];
-
-                sprintf(url,"http://%s%s",lpreq->lpszHostName,lpreq->lpszPath);
-                TRACE("INTERNET_OPTION_URL: %s\n",url);
-                if (*lpdwBufferLength < strlen(url)+1)
+                LPWININETHTTPREQW lpreq = (LPWININETHTTPREQW) lpwhh;
+                WCHAR url[1023];
+                WCHAR szFmt[] = {'h','t','t','p',':','/','/','%','s','%','s',0};
+
+                sprintfW(url,szFmt,lpreq->lpszHostName,lpreq->lpszPath);
+                TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url));
+                if (*lpdwBufferLength < strlenW(url)+1)
                     INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
                 else
                 {
-                    if(bIsUnicode)
+                    if(!bIsUnicode)
                     {
-                        *lpdwBufferLength=MultiByteToWideChar(CP_ACP,0,url,-1,lpBuffer,*lpdwBufferLength);
+                        *lpdwBufferLength=WideCharToMultiByte(CP_ACP,0,url,-1,lpBuffer,*lpdwBufferLength,NULL,NULL);
                     }
                     else
                     {
-                        memcpy(lpBuffer, url, strlen(url)+1);
-                        *lpdwBufferLength = strlen(url)+1;
+                        strcpyW(lpBuffer, url);
+                        *lpdwBufferLength = strlenW(url)+1;
                     }
                     bSuccess = TRUE;
                 }
@@ -2046,18 +2039,18 @@
  * RETURNS
  *   handle of connection or NULL on failure
  */
-HINTERNET WINAPI INTERNET_InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
-    LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
+HINTERNET WINAPI INTERNET_InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
+    LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
 {
-    URL_COMPONENTSA urlComponents;
-    char protocol[32], hostName[MAXHOSTNAME], userName[1024];
-    char password[1024], path[2048], extra[1024];
+    URL_COMPONENTSW urlComponents;
+    WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
+    WCHAR password[1024], path[2048], extra[1024];
     HINTERNET client = NULL, client1 = NULL;
     
-    TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_a(lpszUrl), debugstr_a(lpszHeaders),
+    TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
 	  dwHeadersLength, dwFlags, dwContext);
     
-    urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
+    urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
     urlComponents.lpszScheme = protocol;
     urlComponents.dwSchemeLength = 32;
     urlComponents.lpszHostName = hostName;
@@ -2070,37 +2063,38 @@
     urlComponents.dwUrlPathLength = 2048;
     urlComponents.lpszExtraInfo = extra;
     urlComponents.dwExtraInfoLength = 1024;
-    if(!InternetCrackUrlA(lpszUrl, strlen(lpszUrl), 0, &urlComponents))
+    if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents))
 	return NULL;
     switch(urlComponents.nScheme) {
     case INTERNET_SCHEME_FTP:
 	if(urlComponents.nPort == 0)
 	    urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
-	client = InternetConnectA(hInternet, hostName, urlComponents.nPort,
+	client = InternetConnectW(hInternet, hostName, urlComponents.nPort,
 				  userName, password, INTERNET_SERVICE_FTP, dwFlags, dwContext);
-	client1 = FtpOpenFileA(client, path, GENERIC_READ, dwFlags, dwContext);
+	client1 = FtpOpenFileW(client, path, GENERIC_READ, dwFlags, dwContext);
 	break;
 	
     case INTERNET_SCHEME_HTTP:
     case INTERNET_SCHEME_HTTPS: {
-	LPCSTR accept[2] = { "*/*", NULL };
+	WCHAR szStars[] = { '*','/','*', 0 };
+	LPCWSTR accept[2] = { szStars, NULL };
 	if(urlComponents.nPort == 0) {
 	    if(urlComponents.nScheme == INTERNET_SCHEME_HTTP)
 		urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
 	    else
 		urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
 	}
-	client = InternetConnectA(hInternet, hostName, urlComponents.nPort, userName,
+	client = InternetConnectW(hInternet, hostName, urlComponents.nPort, userName,
 				  password, INTERNET_SERVICE_HTTP, dwFlags, dwContext);
 	if(client == NULL)
 	    break;
-	client1 = HttpOpenRequestA(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
+	client1 = HttpOpenRequestW(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
 	if(client1 == NULL) {
 	    InternetCloseHandle(client);
 	    break;
 	}
-	HttpAddRequestHeadersA(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
-	if (!HTTP_HttpSendRequestA(client1, NULL, 0, NULL, 0)) {
+	HttpAddRequestHeadersW(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
+	if (!HTTP_HttpSendRequestW(client1, NULL, 0, NULL, 0)) {
 	    InternetCloseHandle(client1);
 	    InternetCloseHandle(client);
 	    client1 = NULL;
@@ -2127,13 +2121,13 @@
  * RETURNS
  *   handle of connection or NULL on failure
  */
-HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
-    LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
+HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
+    LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
 {
     HINTERNET ret = NULL;
     LPWININETAPPINFOW hIC = NULL;
 
-    TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_a(lpszUrl), debugstr_a(lpszHeaders),
+    TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
  	  dwHeadersLength, dwFlags, dwContext);
  
     hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
@@ -2144,17 +2138,17 @@
     
     if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) {
 	WORKREQUEST workRequest;
-	struct WORKREQ_INTERNETOPENURLA *req;
+	struct WORKREQ_INTERNETOPENURLW *req;
 	
-	workRequest.asyncall = INTERNETOPENURLA;
+	workRequest.asyncall = INTERNETOPENURLW;
 	workRequest.handle = hInternet;
-	req = &workRequest.u.InternetOpenUrlA;
+	req = &workRequest.u.InternetOpenUrlW;
 	if (lpszUrl)
-	    req->lpszUrl = WININET_strdup(lpszUrl);
+	    req->lpszUrl = WININET_strdupW(lpszUrl);
 	else
 	    req->lpszUrl = 0;
 	if (lpszHeaders)
-	    req->lpszHeaders = WININET_strdup(lpszHeaders);
+	    req->lpszHeaders = WININET_strdupW(lpszHeaders);
 	else
 	    req->lpszHeaders = 0;
 	req->dwHeadersLength = dwHeadersLength;
@@ -2167,7 +2161,7 @@
 	 */
 	SetLastError(ERROR_IO_PENDING);
     } else {
-	ret = INTERNET_InternetOpenUrlA(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
+	ret = INTERNET_InternetOpenUrlW(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
     }
     
   lend:
@@ -2184,15 +2178,15 @@
  * RETURNS
  *   handle of connection or NULL on failure
  */
-HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
-    LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
+HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
+    LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
 {
     HINTERNET rc = (HINTERNET)NULL;
 
-    INT lenUrl = WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, NULL, 0, NULL, NULL);
-    INT lenHeaders = WideCharToMultiByte(CP_ACP, 0, lpszHeaders, -1, NULL, 0, NULL, NULL);
-    CHAR *szUrl = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(CHAR));
-    CHAR *szHeaders = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(CHAR));
+    INT lenUrl = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0 );
+    INT lenHeaders = MultiByteToWideChar(CP_ACP, 0, lpszHeaders, -1, NULL, 0 );
+    LPWSTR szUrl = HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(WCHAR));
+    LPWSTR szHeaders = HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(WCHAR));
 
     TRACE("\n");
 
@@ -2205,12 +2199,10 @@
         return (HINTERNET)NULL;
     }
 
-    WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, szUrl, lenUrl,
-        NULL, NULL);
-    WideCharToMultiByte(CP_ACP, 0, lpszHeaders, -1, szHeaders, lenHeaders,
-        NULL, NULL);
+    MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, lenUrl);
+    MultiByteToWideChar(CP_ACP, 0, lpszHeaders, -1, szHeaders, lenHeaders);
 
-    rc = InternetOpenUrlA(hInternet, szUrl, szHeaders,
+    rc = InternetOpenUrlW(hInternet, szUrl, szHeaders,
         dwHeadersLength, dwFlags, dwContext);
 
     HeapFree(GetProcessHeap(), 0, szUrl);
@@ -2438,10 +2430,10 @@
 	    FE(FTPREMOVEDIRECTORYA),
 	    FE(FTPRENAMEFILEA),
 	    FE(INTERNETFINDNEXTA),
-	    FE(HTTPSENDREQUESTA),
-	    FE(HTTPOPENREQUESTA),
+	    FE(HTTPSENDREQUESTW),
+	    FE(HTTPOPENREQUESTW),
 	    FE(SENDCALLBACK),
-	    FE(INTERNETOPENURLA)
+	    FE(INTERNETOPENURLW)
 #undef FE
 	};
 	int i;
@@ -2571,22 +2563,22 @@
         }
 	break;
 
-    case HTTPSENDREQUESTA:
+    case HTTPSENDREQUESTW:
         {
-        struct WORKREQ_HTTPSENDREQUESTA *req = &workRequest.u.HttpSendRequestA;
+        struct WORKREQ_HTTPSENDREQUESTW *req = &workRequest.u.HttpSendRequestW;
 
-        HTTP_HttpSendRequestA(workRequest.handle, req->lpszHeader,
+        HTTP_HttpSendRequestW(workRequest.handle, req->lpszHeader,
                 req->dwHeaderLength, req->lpOptional, req->dwOptionalLength);
 
         HeapFree(GetProcessHeap(), 0, req->lpszHeader);
         }
         break;
 
-    case HTTPOPENREQUESTA:
+    case HTTPOPENREQUESTW:
         {
-        struct WORKREQ_HTTPOPENREQUESTA *req = &workRequest.u.HttpOpenRequestA;
+        struct WORKREQ_HTTPOPENREQUESTW *req = &workRequest.u.HttpOpenRequestW;
 
-        HTTP_HttpOpenRequestA(workRequest.handle, req->lpszVerb,
+        HTTP_HttpOpenRequestW(workRequest.handle, req->lpszVerb,
             req->lpszObjectName, req->lpszVersion, req->lpszReferrer,
             req->lpszAcceptTypes, req->dwFlags, req->dwContext);
 
@@ -2607,11 +2599,11 @@
         }
         break;
 
-    case INTERNETOPENURLA:
+    case INTERNETOPENURLW:
 	{
-	struct WORKREQ_INTERNETOPENURLA *req = &workRequest.u.InternetOpenUrlA;
+	struct WORKREQ_INTERNETOPENURLW *req = &workRequest.u.InternetOpenUrlW;
 	
-	INTERNET_InternetOpenUrlA(workRequest.handle, req->lpszUrl,
+	INTERNET_InternetOpenUrlW(workRequest.handle, req->lpszUrl,
 				  req->lpszHeaders, req->dwHeadersLength, req->dwFlags, req->dwContext);
 	HeapFree(GetProcessHeap(), 0, req->lpszUrl);
 	HeapFree(GetProcessHeap(), 0, req->lpszHeaders);
@@ -2705,12 +2697,12 @@
                                 LPDWORD lpdwNumberOfBytesAvailble,
                                 DWORD dwFlags, DWORD dwConext)
 {
-    LPWININETHTTPREQA lpwhr;
+    LPWININETHTTPREQW lpwhr;
     INT retval = -1;
     char buffer[4048];
 
 
-    lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hFile );
+    lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hFile );
     if (NULL == lpwhr)
     {
         SetLastError(ERROR_NO_MORE_FILES);
Index: dlls/wininet/internet.h
===================================================================
RCS file: /home/wine/wine/dlls/wininet/internet.h,v
retrieving revision 1.22
diff -u -r1.22 internet.h
--- dlls/wininet/internet.h	25 Mar 2004 05:29:47 -0000	1.22
+++ dlls/wininet/internet.h	28 Mar 2004 05:33:00 -0000
@@ -23,6 +23,8 @@
 #ifndef _WINE_INTERNET_H_
 #define _WINE_INTERNET_H_
 
+#include "wine/unicode.h"
+
 #include <time.h>
 #ifdef HAVE_NETDB_H
 # include <netdb.h>
@@ -61,6 +63,13 @@
     return ret;
 }
 
+inline static LPWSTR WININET_strdupW( LPCWSTR str )
+{
+    LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1)*sizeof(WCHAR) );
+    if (ret) strcpyW( ret, str );
+    return ret;
+}
+
 typedef enum
 {
     WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET,
@@ -98,12 +107,12 @@
 typedef struct
 {
     WININETHANDLEHEADER hdr;
-    LPSTR  lpszServerName;
-    LPSTR  lpszUserName;
+    LPWSTR  lpszServerName;
+    LPWSTR  lpszUserName;
     INTERNET_PORT nServerPort;
     struct sockaddr_in socketAddress;
     struct hostent *phostent;
-} WININETHTTPSESSIONA, *LPWININETHTTPSESSIONA;
+} WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
 
 #define HDR_ISREQUEST		0x0001
 #define HDR_COMMADELIMITED	0x0002
@@ -111,24 +120,24 @@
 
 typedef struct
 {
-    LPSTR lpszField;
-    LPSTR lpszValue;
+    LPWSTR lpszField;
+    LPWSTR lpszValue;
     WORD wFlags;
     WORD wCount;
-} HTTPHEADERA, *LPHTTPHEADERA;
+} HTTPHEADERW, *LPHTTPHEADERW;
 
 
 typedef struct
 {
     WININETHANDLEHEADER hdr;
-    LPSTR lpszPath;
-    LPSTR lpszVerb;
-    LPSTR lpszHostName;
+    LPWSTR lpszPath;
+    LPWSTR lpszVerb;
+    LPWSTR lpszHostName;
     WININET_NETCONNECTION netConnection;
-    HTTPHEADERA StdHeaders[HTTP_QUERY_MAX+1];
-    HTTPHEADERA *pCustHeaders;
+    HTTPHEADERW StdHeaders[HTTP_QUERY_MAX+1];
+    HTTPHEADERW *pCustHeaders;
     INT nCustHeaders;
-} WININETHTTPREQA, *LPWININETHTTPREQA;
+} WININETHTTPREQW, *LPWININETHTTPREQW;
 
 
 typedef struct
@@ -185,10 +194,10 @@
     FTPREMOVEDIRECTORYA,
     FTPRENAMEFILEA,
     INTERNETFINDNEXTA,
-    HTTPSENDREQUESTA,
-    HTTPOPENREQUESTA,
+    HTTPSENDREQUESTW,
+    HTTPOPENREQUESTW,
     SENDCALLBACK,
-    INTERNETOPENURLA,
+    INTERNETOPENURLW,
 } ASYNC_FUNC;
 
 struct WORKREQ_FTPPUTFILEA
@@ -262,20 +271,20 @@
     LPWIN32_FIND_DATAA lpFindFileData;
 };
 
-struct WORKREQ_HTTPOPENREQUESTA
+struct WORKREQ_HTTPOPENREQUESTW
 {
-    LPSTR lpszVerb;
-    LPSTR lpszObjectName;
-    LPSTR lpszVersion;
-    LPSTR lpszReferrer;
-    LPCSTR *lpszAcceptTypes;
+    LPWSTR lpszVerb;
+    LPWSTR lpszObjectName;
+    LPWSTR lpszVersion;
+    LPWSTR lpszReferrer;
+    LPCWSTR *lpszAcceptTypes;
     DWORD  dwFlags;
     DWORD  dwContext;
 };
 
-struct WORKREQ_HTTPSENDREQUESTA
+struct WORKREQ_HTTPSENDREQUESTW
 {
-    LPSTR lpszHeader;
+    LPWSTR lpszHeader;
     DWORD  dwHeaderLength;
     LPVOID lpOptional;
     DWORD  dwOptionalLength;
@@ -290,11 +299,11 @@
     DWORD     dwStatusInfoLength;
 };
 
-struct WORKREQ_INTERNETOPENURLA
+struct WORKREQ_INTERNETOPENURLW
 {
     HINTERNET hInternet;
-    LPSTR     lpszUrl;
-    LPSTR     lpszHeaders;
+    LPWSTR     lpszUrl;
+    LPWSTR     lpszHeaders;
     DWORD     dwHeadersLength;
     DWORD     dwFlags;
     DWORD     dwContext;
@@ -317,10 +326,10 @@
         struct WORKREQ_FTPREMOVEDIRECTORYA      FtpRemoveDirectoryA;
         struct WORKREQ_FTPRENAMEFILEA           FtpRenameFileA;
         struct WORKREQ_INTERNETFINDNEXTA        InternetFindNextA;
-        struct WORKREQ_HTTPOPENREQUESTA         HttpOpenRequestA;
-        struct WORKREQ_HTTPSENDREQUESTA         HttpSendRequestA;
+        struct WORKREQ_HTTPOPENREQUESTW         HttpOpenRequestW;
+        struct WORKREQ_HTTPSENDREQUESTW         HttpSendRequestW;
         struct WORKREQ_SENDCALLBACK             SendCallback;
-	struct WORKREQ_INTERNETOPENURLA         InternetOpenUrlA;
+	struct WORKREQ_INTERNETOPENURLW         InternetOpenUrlW;
     } u;
 
     struct WORKREQ *next;
@@ -333,17 +342,17 @@
 BOOL WININET_FreeHandle( HINTERNET hinternet );
 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
 
-time_t ConvertTimeString(LPCSTR asctime);
+time_t ConvertTimeString(LPCWSTR asctime);
 
-HINTERNET FTP_Connect(HINTERNET hInterent, LPCSTR lpszServerName,
-	INTERNET_PORT nServerPort, LPCSTR lpszUserName,
-	LPCSTR lpszPassword, DWORD dwFlags, DWORD dwContext);
+HINTERNET FTP_Connect(HINTERNET hInterent, LPCWSTR lpszServerName,
+	INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
+	LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext);
 
-HINTERNET HTTP_Connect(HINTERNET hInterent, LPCSTR lpszServerName,
-	INTERNET_PORT nServerPort, LPCSTR lpszUserName,
-	LPCSTR lpszPassword, DWORD dwFlags, DWORD dwContext);
+HINTERNET HTTP_Connect(HINTERNET hInterent, LPCWSTR lpszServerName,
+	INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
+	LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext);
 
-BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
+BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
 	struct hostent **phe, struct sockaddr_in *psa);
 
 void INTERNET_SetLastError(DWORD dwError);
@@ -373,14 +382,14 @@
 	BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
 	DWORD dwContext);
 
-BOOLAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
+BOOLAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
 	DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
-INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
-	LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion,
-	LPCSTR lpszReferrer , LPCSTR *lpszAcceptTypes,
+INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
+	LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
+	LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
 	DWORD dwFlags, DWORD dwContext);
-void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs);
-void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr);
+void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONW lpwhs);
+void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQW lpwhr);
 
 VOID SendAsyncCallback(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
                              DWORD dwContext, DWORD dwInternetStatus, LPVOID
@@ -390,7 +399,7 @@
                              DWORD dwContext, DWORD dwInternetStatus, LPVOID
                              lpvStatusInfo , DWORD dwStatusInfoLength);
 
-BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQA lpwhr,
+BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
                        LPCWSTR username, LPCWSTR password );
 
 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
Index: dlls/wininet/netconnection.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/netconnection.c,v
retrieving revision 1.6
diff -u -r1.6 netconnection.c
--- dlls/wininet/netconnection.c	27 Feb 2004 21:32:54 -0000	1.6
+++ dlls/wininet/netconnection.c	28 Mar 2004 05:33:00 -0000
@@ -26,7 +26,9 @@
 #ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
 #endif
-#include <sys/types.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
 #ifdef HAVE_SYS_SOCKET_H
 # include <sys/socket.h>
 #endif
@@ -446,8 +448,8 @@
     lend:             /* FIXME: don't use labels */
 	if (bSuccess)
 	{
-	    lpszBuffer[nRecv] = '\0';
-	    *dwBuffer = nRecv - 1;
+	    lpszBuffer[nRecv++] = '\0';
+	    *dwBuffer = nRecv;
 	    TRACE(":%d %s\n", nRecv, lpszBuffer);
             return TRUE;
 	}
@@ -487,8 +489,8 @@
         pSSL_CTX_set_timeout(ctx, prev_timeout);
 	if (success)
 	{
-	    lpszBuffer[nRecv] = '\0';
-	    *dwBuffer = nRecv - 1;
+	    lpszBuffer[nRecv++] = '\0';
+	    *dwBuffer = nRecv;
 	    TRACE("_SSL:%d %s\n", nRecv, lpszBuffer);
             return TRUE;
 	}
Index: dlls/wininet/utility.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/utility.c,v
retrieving revision 1.15
diff -u -r1.15 utility.c
--- dlls/wininet/utility.c	25 Mar 2004 05:29:47 -0000	1.15
+++ dlls/wininet/utility.c	28 Mar 2004 05:33:00 -0000
@@ -33,6 +33,7 @@
 #include "winbase.h"
 #include "wininet.h"
 #include "winerror.h"
+#include "winnls.h"
 
 #include "wine/debug.h"
 #include "internet.h"
@@ -41,17 +42,17 @@
 
 #define TIME_STRING_LEN  30
 
-time_t ConvertTimeString(LPCSTR asctime)
+time_t ConvertTimeString(LPCWSTR asctime)
 {
-    char tmpChar[TIME_STRING_LEN];
-    char *tmpChar2;
+    WCHAR tmpChar[TIME_STRING_LEN];
+    WCHAR *tmpChar2;
     struct tm t;
-    int timelen = strlen(asctime);
+    int timelen = strlenW(asctime);
 
     if(!asctime || !timelen)
         return 0;
 
-    strncpy(tmpChar, asctime, TIME_STRING_LEN);
+    strncpyW(tmpChar, asctime, TIME_STRING_LEN);
 
     /* Assert that the string is the expected length */
     if (tmpChar[TIME_STRING_LEN] != '\0')
@@ -72,11 +73,11 @@
     tmpChar[22]='\0';
     tmpChar[25]='\0';
 
-    t.tm_year = atoi(tmpChar+12) - 1900;
-    t.tm_mday = atoi(tmpChar+5);
-    t.tm_hour = atoi(tmpChar+17);
-    t.tm_min = atoi(tmpChar+20);
-    t.tm_sec = atoi(tmpChar+23);
+    t.tm_year = atoiW(tmpChar+12) - 1900;
+    t.tm_mday = atoiW(tmpChar+5);
+    t.tm_hour = atoiW(tmpChar+17);
+    t.tm_min = atoiW(tmpChar+20);
+    t.tm_sec = atoiW(tmpChar+23);
 
     /* and month */
     tmpChar2 = tmpChar + 8;
@@ -126,34 +127,36 @@
 }
 
 
-BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
+BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
 	struct hostent **phe, struct sockaddr_in *psa)
 {
-    char *found;
+    WCHAR *found;
+    char *name;
+    int len, sz;
 
-    TRACE("%s\n", lpszServerName);
+    TRACE("%s\n", debugstr_w(lpszServerName));
 
     /* Validate server name first
      * Check if there is sth. like
      * pinger.macromedia.com:80
      * if yes, eliminate the :80....
      */
-    found = strchr(lpszServerName, ':');
+    found = strchrW(lpszServerName, ':');
     if (found)
-    {
-        int len = found - lpszServerName;
-        char *new = HeapAlloc(GetProcessHeap(), 0, len + 1);
-        memcpy( new, lpszServerName, len );
-        new[len] = '\0';
-        TRACE("Found a ':' inside the server name, reparsed name: %s\n", new);
-        *phe = gethostbyname(new);
-        HeapFree( GetProcessHeap(), 0, new );
-    }
-    else *phe = gethostbyname(lpszServerName);
+        len = found - lpszServerName;
+    else
+        len = strlenW(lpszServerName);
+
+    sz = WideCharToMultiByte( CP_UNIXCP, 0, lpszServerName, len, NULL, 0, NULL, NULL );
+    name = HeapAlloc(GetProcessHeap(), 0, sz+1);
+    WideCharToMultiByte( CP_UNIXCP, 0, lpszServerName, len, name, sz, NULL, NULL );
+    name[sz] = 0;
+    *phe = gethostbyname(name);
+    HeapFree( GetProcessHeap(), 0, name );
 
     if (NULL == *phe)
     {
-        TRACE("Failed to get hostname: (%s)\n", lpszServerName);
+        TRACE("Failed to get hostname: (%s)\n", debugstr_w(lpszServerName) );
         return FALSE;
     }
 
Index: dlls/wininet/wininet.spec
===================================================================
RCS file: /home/wine/wine/dlls/wininet/wininet.spec,v
retrieving revision 1.45
diff -u -r1.45 wininet.spec
--- dlls/wininet/wininet.spec	12 Dec 2003 06:01:20 -0000	1.45
+++ dlls/wininet/wininet.spec	28 Mar 2004 05:33:00 -0000
@@ -89,7 +89,7 @@
 @ stdcall GopherOpenFileA(ptr str str long long)
 @ stdcall GopherOpenFileW(ptr wstr wstr long long)
 @ stdcall HttpAddRequestHeadersA(ptr str long long)
-@ stub HttpAddRequestHeadersW
+@ stdcall HttpAddRequestHeadersW(ptr wstr long long)
 @ stdcall HttpEndRequestA(ptr ptr long long)
 @ stdcall HttpEndRequestW(ptr ptr long long)
 @ stdcall HttpOpenRequestA(ptr str str str str ptr long long)


More information about the wine-patches mailing list