/*********************************************************************** * 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 ) { http_request_t *request; http_session_t *session = NULL; appinfo_t *hIC = NULL; BOOL ret = FALSE; LPWSTR p; request = (http_request_t*) get_handle_object( hRequest ); if (NULL == request) return FALSE; session = request->session; if (NULL == session) goto done; hIC = session->appInfo; if (NULL == hIC) goto done; lstrcpynW(szBuf, hIC->proxy, sz); /* FIXME: perhaps it would be better to use InternetCrackUrl here */ p = strchrW(szBuf, ':'); if (p) *p = 0; ret = TRUE; done: WININET_Release( &request->hdr ); return ret; }
/*********************************************************************** * WININET_SetAuthorization */ static BOOL WININET_SetAuthorization( HINTERNET hRequest, LPWSTR username, LPWSTR password, BOOL proxy ) { http_request_t *request; http_session_t *session; BOOL ret = FALSE; LPWSTR p, q; request = (http_request_t*) get_handle_object( hRequest ); if( !request ) return FALSE; session = request->session; if (NULL == session || session->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 ) { heap_free(username); goto done; } if (proxy) { appinfo_t *hIC = session->appInfo; heap_free(hIC->proxyUsername); hIC->proxyUsername = p; heap_free(hIC->proxyPassword); hIC->proxyPassword = q; } else { heap_free(session->userName); session->userName = p; heap_free(session->password); session->password = q; } ret = TRUE; done: WININET_Release( &request->hdr ); return ret; }
/*********************************************************************** * 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; }
VOID INTERNET_SendCallback(LPWININETHANDLEHEADER hdr, DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) { HINTERNET hHttpSession; LPVOID lpvNewInfo = NULL; if( !hdr->lpfnStatusCB ) return; /* the IE5 version of wininet does not send callbacks if dwContext is zero */ if( !dwContext ) return; hHttpSession = WININET_FindHandle( hdr ); if( !hHttpSession ) { TRACE(" Could not convert header '%p' into a handle !\n", hdr); return; } lpvNewInfo = lpvStatusInfo; if(hdr->dwInternalFlags & INET_CALLBACKW) { switch(dwInternetStatus) { case INTERNET_STATUS_NAME_RESOLVED: case INTERNET_STATUS_CONNECTING_TO_SERVER: case INTERNET_STATUS_CONNECTED_TO_SERVER: lpvNewInfo = WININET_strdup_AtoW(lpvStatusInfo); } }else { switch(dwInternetStatus) { case INTERNET_STATUS_RESOLVING_NAME: case INTERNET_STATUS_REDIRECT: lpvNewInfo = WININET_strdup_WtoA(lpvStatusInfo); } } TRACE(" callback(%p) (%p (%p), %08lx, %ld (%s), %p, %ld)\n", hdr->lpfnStatusCB, hHttpSession, hdr, dwContext, dwInternetStatus, get_callback_name(dwInternetStatus), lpvNewInfo, dwStatusInfoLength); hdr->lpfnStatusCB(hHttpSession, dwContext, dwInternetStatus, lpvNewInfo, dwStatusInfoLength); TRACE(" end callback().\n"); if(lpvNewInfo != lpvStatusInfo) HeapFree(GetProcessHeap(), 0, lpvNewInfo); WININET_Release( hdr ); }
/*********************************************************************** * WININET_GetServer * * Determine the name of the web server */ static BOOL WININET_GetServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz ) { http_request_t *request; http_session_t *session = NULL; BOOL ret = FALSE; request = (http_request_t*) get_handle_object( hRequest ); if (NULL == request) return FALSE; session = request->session; if (NULL == session) goto done; lstrcpynW(szBuf, session->hostName, sz); ret = TRUE; done: WININET_Release( &request->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; }
/*********************************************************************** * InternetErrorDlg */ DWORD WINAPI InternetErrorDlg(HWND hWnd, HINTERNET hRequest, DWORD dwError, DWORD dwFlags, LPVOID* lppvData) { struct WININET_ErrorDlgParams params; http_request_t *req = NULL; DWORD res = ERROR_SUCCESS; TRACE("%p %p %d %08x %p\n", hWnd, hRequest, dwError, dwFlags, lppvData); if( !hWnd && !(dwFlags & FLAGS_ERROR_UI_FLAGS_NO_UI) ) return ERROR_INVALID_HANDLE; if(hRequest) { req = (http_request_t*)get_handle_object(hRequest); if(!req) return ERROR_INVALID_HANDLE; if(req->hdr.htype != WH_HHTTPREQ) return ERROR_SUCCESS; /* Yes, that was tested */ } params.req = req; params.hWnd = hWnd; params.dwError = dwError; params.dwFlags = dwFlags; params.lppvData = lppvData; switch( dwError ) { case ERROR_SUCCESS: case ERROR_INTERNET_INCORRECT_PASSWORD: { if( !dwError && !(dwFlags & FLAGS_ERROR_UI_FILTER_FOR_ERRORS ) ) break; if(!req) return ERROR_INVALID_HANDLE; switch(req->status_code) { case HTTP_STATUS_PROXY_AUTH_REQ: res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_PROXYDLG ), hWnd, WININET_ProxyPasswordDialog, (LPARAM) ¶ms ); break; case HTTP_STATUS_DENIED: res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_AUTHDLG ), hWnd, WININET_PasswordDialog, (LPARAM) ¶ms ); break; default: WARN("unhandled status %u\n", req->status_code); } break; } case ERROR_INTERNET_SEC_CERT_ERRORS: case ERROR_INTERNET_SEC_CERT_CN_INVALID: case ERROR_INTERNET_SEC_CERT_DATE_INVALID: case ERROR_INTERNET_INVALID_CA: case ERROR_INTERNET_SEC_CERT_REV_FAILED: if( dwFlags & FLAGS_ERROR_UI_FLAGS_NO_UI ) { res = ERROR_CANCELLED; break; } if(!req) return ERROR_INVALID_HANDLE; if( dwFlags & ~FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS ) FIXME("%08x contains unsupported flags.\n", dwFlags); res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_INVCERTDLG ), hWnd, WININET_InvalidCertificateDialog, (LPARAM) ¶ms ); break; case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR: case ERROR_INTERNET_POST_IS_NON_SECURE: FIXME("Need to display dialog for error %d\n", dwError); res = ERROR_SUCCESS; break; default: res = ERROR_NOT_SUPPORTED; } if(req) WININET_Release(&req->hdr); return res; }