/*********************************************************************** * WININET_GetProxyServer * * Determine the name of the proxy server the request is using */ static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz ) { http_request_t *lpwhr; http_session_t *lpwhs = NULL; appinfo_t *hIC = NULL; BOOL ret = FALSE; LPWSTR p; lpwhr = (http_request_t*) WININET_GetObject( hRequest ); if (NULL == lpwhr) return FALSE; lpwhs = lpwhr->lpHttpSession; if (NULL == lpwhs) goto done; hIC = lpwhs->lpAppInfo; if (NULL == hIC) goto done; lstrcpynW(szBuf, hIC->lpszProxy, sz); /* FIXME: perhaps it would be better to use InternetCrackUrl here */ p = strchrW(szBuf, ':'); if (p) *p = 0; ret = TRUE; done: WININET_Release( &lpwhr->hdr ); return ret; }
/*********************************************************************** * WININET_GetProxyServer * * Determine the name of the proxy server the request is using */ static BOOL WININET_GetProxyServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz ) { LPWININETHTTPREQW lpwhr; LPWININETHTTPSESSIONW lpwhs = NULL; LPWININETAPPINFOW hIC = NULL; LPWSTR p; lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hRequest ); if (NULL == lpwhr) return FALSE; lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent; if (NULL == lpwhs) return FALSE; hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; if (NULL == hIC) return FALSE; lstrcpynW(szBuf, hIC->lpszProxy, sz); /* FIXME: perhaps it would be better to use InternetCrackUrl here */ p = strchrW(szBuf, ':'); if (p) *p = 0; return TRUE; }
/*********************************************************************** * WININET_SetAuthorization */ static BOOL WININET_SetAuthorization( HINTERNET hRequest, LPWSTR username, LPWSTR password, BOOL proxy ) { http_request_t *lpwhr; http_session_t *lpwhs; BOOL ret = FALSE; LPWSTR p, q; lpwhr = (http_request_t*) WININET_GetObject( hRequest ); if( !lpwhr ) return FALSE; lpwhs = lpwhr->lpHttpSession; if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION) { INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); goto done; } p = heap_strdupW(username); if( !p ) goto done; q = heap_strdupW(password); if( !q ) { HeapFree(GetProcessHeap(), 0, username); goto done; } if (proxy) { appinfo_t *hIC = lpwhs->lpAppInfo; HeapFree(GetProcessHeap(), 0, hIC->lpszProxyUsername); hIC->lpszProxyUsername = p; HeapFree(GetProcessHeap(), 0, hIC->lpszProxyPassword); hIC->lpszProxyPassword = q; } else { HeapFree(GetProcessHeap(), 0, lpwhs->lpszUserName); lpwhs->lpszUserName = p; HeapFree(GetProcessHeap(), 0, lpwhs->lpszPassword); lpwhs->lpszPassword = q; } ret = TRUE; done: WININET_Release( &lpwhr->hdr ); return ret; }
/*********************************************************************** * WININET_GetServer * * Determine the name of the web server */ static BOOL WININET_GetServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz ) { http_request_t *lpwhr; http_session_t *lpwhs = NULL; BOOL ret = FALSE; lpwhr = (http_request_t*) WININET_GetObject( hRequest ); if (NULL == lpwhr) return FALSE; lpwhs = lpwhr->lpHttpSession; if (NULL == lpwhs) goto done; lstrcpynW(szBuf, lpwhs->lpszHostName, sz); ret = TRUE; done: WININET_Release( &lpwhr->hdr ); return ret; }
/*********************************************************************** * WININET_SetProxyAuthorization */ static BOOL WININET_SetProxyAuthorization( HINTERNET hRequest, LPWSTR username, LPWSTR password ) { LPWININETHTTPREQW lpwhr; LPWININETHTTPSESSIONW lpwhs; LPWININETAPPINFOW hIC; LPWSTR p; lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hRequest ); if( !lpwhr ) return FALSE; lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent; if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION) { INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); return FALSE; } hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent; p = HeapAlloc( GetProcessHeap(), 0, (strlenW( username ) + 1)*sizeof(WCHAR) ); if( !p ) return FALSE; lstrcpyW( p, username ); hIC->lpszProxyUsername = p; p = HeapAlloc( GetProcessHeap(), 0, (strlenW( password ) + 1)*sizeof(WCHAR) ); if( !p ) return FALSE; lstrcpyW( p, password ); hIC->lpszProxyPassword = p; return TRUE; }