mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
[WININET]
* Sync with Wine 1.7.27. CORE-8540 svn path=/trunk/; revision=64276
This commit is contained in:
parent
3b4680b994
commit
00a55fe1f3
10 changed files with 836 additions and 657 deletions
|
@ -19,7 +19,6 @@ list(APPEND SOURCE
|
|||
netconnection.c
|
||||
urlcache.c
|
||||
utility.c
|
||||
wininet_main.c
|
||||
internet.h)
|
||||
|
||||
add_library(wininet SHARED
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1153,7 +1153,7 @@ static DWORD FTPFILE_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DW
|
|||
return ERROR_INTERNET_DISCONNECTED;
|
||||
|
||||
/* FIXME: FTP should use NETCON_ stuff */
|
||||
res = recv(file->nDataSocket, buffer, size, MSG_WAITALL);
|
||||
res = sock_recv(file->nDataSocket, buffer, size, MSG_WAITALL);
|
||||
*read = res>0 ? res : 0;
|
||||
|
||||
error = res >= 0 ? ERROR_SUCCESS : INTERNET_ERROR_BASE; /* FIXME */
|
||||
|
@ -1178,7 +1178,7 @@ static DWORD FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD s
|
|||
ftp_file_t *lpwh = (ftp_file_t*) hdr;
|
||||
int res;
|
||||
|
||||
res = send(lpwh->nDataSocket, buffer, size, 0);
|
||||
res = sock_send(lpwh->nDataSocket, buffer, size, 0);
|
||||
|
||||
*written = res>0 ? res : 0;
|
||||
return res >= 0 ? ERROR_SUCCESS : sock_get_error(errno);
|
||||
|
@ -1192,7 +1192,7 @@ static void FTP_ReceiveRequestData(ftp_file_t *file, BOOL first_notif)
|
|||
|
||||
TRACE("%p\n", file);
|
||||
|
||||
available = recv(file->nDataSocket, buffer, sizeof(buffer), MSG_PEEK);
|
||||
available = sock_recv(file->nDataSocket, buffer, sizeof(buffer), MSG_PEEK);
|
||||
|
||||
if(available != -1) {
|
||||
iar.dwResult = (DWORD_PTR)file->hdr.hInternet;
|
||||
|
@ -1235,7 +1235,7 @@ static DWORD FTPFILE_QueryDataAvailable(object_header_t *hdr, DWORD *available,
|
|||
|
||||
*available = 0;
|
||||
|
||||
retval = recv(file->nDataSocket, &byte, 1, MSG_PEEK);
|
||||
retval = sock_recv(file->nDataSocket, &byte, 1, MSG_PEEK);
|
||||
if(retval > 0) {
|
||||
task_header_t *task;
|
||||
|
||||
|
@ -2274,7 +2274,7 @@ BOOL WINAPI FtpCommandW( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags
|
|||
TRACE("Sending (%s) len(%d)\n", cmd, len);
|
||||
while ((nBytesSent < len) && (nRC != -1))
|
||||
{
|
||||
nRC = send(lpwfs->sndSocket, cmd + nBytesSent, len - nBytesSent, 0);
|
||||
nRC = sock_send(lpwfs->sndSocket, cmd + nBytesSent, len - nBytesSent, 0);
|
||||
if (nRC != -1)
|
||||
{
|
||||
nBytesSent += nRC;
|
||||
|
@ -2641,7 +2641,7 @@ static BOOL FTP_SendCommandA(INT nSocket, FTP_COMMAND ftpCmd, LPCSTR lpszParam,
|
|||
TRACE("Sending (%s) len(%d)\n", buf, len);
|
||||
while((nBytesSent < len) && (nRC != -1))
|
||||
{
|
||||
nRC = send(nSocket, buf+nBytesSent, len - nBytesSent, 0);
|
||||
nRC = sock_send(nSocket, buf+nBytesSent, len - nBytesSent, 0);
|
||||
nBytesSent += nRC;
|
||||
}
|
||||
heap_free(buf);
|
||||
|
@ -3221,7 +3221,7 @@ static BOOL FTP_SendData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE hFile)
|
|||
|
||||
nLen = DATA_PACKET_SIZE < nBytesToSend ?
|
||||
DATA_PACKET_SIZE : nBytesToSend;
|
||||
nRC = send(nDataSocket, lpszBuffer, nLen, 0);
|
||||
nRC = sock_send(nDataSocket, lpszBuffer, nLen, 0);
|
||||
|
||||
if (nRC != -1)
|
||||
{
|
||||
|
@ -3326,7 +3326,7 @@ static BOOL FTP_RetrieveFileData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE h
|
|||
|
||||
while (nRC != -1)
|
||||
{
|
||||
nRC = recv(nDataSocket, lpszBuffer, DATA_PACKET_SIZE, 0);
|
||||
nRC = sock_recv(nDataSocket, lpszBuffer, DATA_PACKET_SIZE, 0);
|
||||
if (nRC != -1)
|
||||
{
|
||||
/* other side closed socket. */
|
||||
|
|
|
@ -299,7 +299,11 @@ BOOL collect_connections(collect_type_t collect_type)
|
|||
BOOL remaining = FALSE;
|
||||
DWORD64 now;
|
||||
|
||||
#ifdef __REACTOS__
|
||||
now = GetTickCount();
|
||||
#else
|
||||
now = GetTickCount64();
|
||||
#endif
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(server, server_safe, &connection_pool, server_t, entry) {
|
||||
LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) {
|
||||
|
@ -740,7 +744,7 @@ static void HTTP_ProcessCookies( http_request_t *request )
|
|||
continue;
|
||||
|
||||
data++;
|
||||
set_cookie(host->lpszValue, request->path, name, data);
|
||||
set_cookie(host->lpszValue, request->path, name, data, INTERNET_COOKIE_HTTPONLY);
|
||||
heap_free(name);
|
||||
}
|
||||
}
|
||||
|
@ -1951,7 +1955,7 @@ static void http_release_netconn(http_request_t *req, BOOL reuse)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
// silence unused function warning
|
||||
/* Silence unused function warning */
|
||||
(void)collect_connections_proc;
|
||||
#endif
|
||||
|
||||
|
@ -2859,10 +2863,11 @@ static const data_stream_vtbl_t chunked_stream_vtbl = {
|
|||
static DWORD set_content_length(http_request_t *request)
|
||||
{
|
||||
static const WCHAR szChunked[] = {'c','h','u','n','k','e','d',0};
|
||||
static const WCHAR headW[] = {'H','E','A','D',0};
|
||||
WCHAR encoding[20];
|
||||
DWORD size;
|
||||
|
||||
if(request->status_code == HTTP_STATUS_NO_CONTENT) {
|
||||
if(request->status_code == HTTP_STATUS_NO_CONTENT || !strcmpW(request->verb, headW)) {
|
||||
request->contentLength = request->netconn_stream.content_length = 0;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
@ -3346,9 +3351,6 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
|
|||
|
||||
HTTP_ProcessHeader(request, hostW, request->server->canon_host_port, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ);
|
||||
|
||||
if (session->hostPort == INTERNET_INVALID_PORT_NUMBER)
|
||||
session->hostPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
|
||||
if (hIC->proxy && hIC->proxy[0] && !HTTP_ShouldBypassProxy(hIC, session->hostName))
|
||||
HTTP_DealWithProxy( hIC, session, request );
|
||||
|
||||
|
@ -3673,8 +3675,6 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel,
|
|||
return ERROR_HTTP_HEADER_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (lpdwIndex) (*lpdwIndex)++;
|
||||
|
||||
/* coalesce value to requested type */
|
||||
if (dwInfoLevel & HTTP_QUERY_FLAG_NUMBER && lpBuffer)
|
||||
{
|
||||
|
@ -3720,6 +3720,7 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel,
|
|||
}
|
||||
*lpdwBufferLength = len - sizeof(WCHAR);
|
||||
}
|
||||
if (lpdwIndex) (*lpdwIndex)++;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -3955,9 +3956,9 @@ static LPWSTR HTTP_GetRedirectURL(http_request_t *request, LPCWSTR lpszUrl)
|
|||
urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
|
||||
urlComponents.lpszScheme = (request->hdr.dwFlags & INTERNET_FLAG_SECURE) ? szHttps : szHttp;
|
||||
urlComponents.dwSchemeLength = 0;
|
||||
urlComponents.lpszHostName = session->hostName;
|
||||
urlComponents.lpszHostName = request->server->name;
|
||||
urlComponents.dwHostNameLength = 0;
|
||||
urlComponents.nPort = session->hostPort;
|
||||
urlComponents.nPort = request->server->port;
|
||||
urlComponents.lpszUserName = session->userName;
|
||||
urlComponents.dwUserNameLength = 0;
|
||||
urlComponents.lpszPassword = NULL;
|
||||
|
@ -4082,6 +4083,7 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl)
|
|||
}
|
||||
else
|
||||
session->hostName = heap_strdupW(hostName);
|
||||
session->hostPort = urlComponents.nPort;
|
||||
|
||||
HTTP_ProcessHeader(request, hostW, session->hostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
|
||||
|
||||
|
@ -4154,68 +4156,17 @@ static LPWSTR HTTP_build_req( LPCWSTR *list, int len )
|
|||
return str;
|
||||
}
|
||||
|
||||
static DWORD HTTP_SecureProxyConnect(http_request_t *request)
|
||||
{
|
||||
server_t *server = request->server;
|
||||
LPWSTR requestString;
|
||||
INT len;
|
||||
INT cnt;
|
||||
INT responseLen;
|
||||
char *ascii_req;
|
||||
DWORD res;
|
||||
|
||||
static const WCHAR connectW[] = {'C','O','N','N','E','C','T',0};
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
requestString = build_request_header( request, connectW, server->host_port, g_szHttp1_1, TRUE );
|
||||
|
||||
len = WideCharToMultiByte( CP_ACP, 0, requestString, -1,
|
||||
NULL, 0, NULL, NULL );
|
||||
len--; /* the nul terminator isn't needed */
|
||||
ascii_req = heap_alloc(len);
|
||||
WideCharToMultiByte( CP_ACP, 0, requestString, -1, ascii_req, len, NULL, NULL );
|
||||
heap_free( requestString );
|
||||
|
||||
TRACE("full request -> %s\n", debugstr_an( ascii_req, len ) );
|
||||
|
||||
NETCON_set_timeout( request->netconn, TRUE, request->send_timeout );
|
||||
res = NETCON_send( request->netconn, ascii_req, len, 0, &cnt );
|
||||
heap_free( ascii_req );
|
||||
if (res != ERROR_SUCCESS)
|
||||
return res;
|
||||
|
||||
if (HTTP_GetResponseHeaders( request, &responseLen ) || !responseLen)
|
||||
return ERROR_HTTP_INVALID_HEADER;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static void HTTP_InsertCookies(http_request_t *request)
|
||||
{
|
||||
DWORD cookie_size, size, cnt = 0;
|
||||
HTTPHEADERW *host;
|
||||
WCHAR *cookies;
|
||||
DWORD res;
|
||||
|
||||
static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' ',0};
|
||||
|
||||
host = HTTP_GetHeader(request, hostW);
|
||||
if(!host)
|
||||
res = get_cookie_header(request->server->name, request->path, &cookies);
|
||||
if(res != ERROR_SUCCESS || !cookies)
|
||||
return;
|
||||
|
||||
if(get_cookie(host->lpszValue, request->path, NULL, &cookie_size) != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
size = sizeof(cookieW) + cookie_size * sizeof(WCHAR) + sizeof(szCrLf);
|
||||
if(!(cookies = heap_alloc(size)))
|
||||
return;
|
||||
|
||||
cnt += sprintfW(cookies, cookieW);
|
||||
get_cookie(host->lpszValue, request->path, cookies+cnt, &cookie_size);
|
||||
strcatW(cookies, szCrLf);
|
||||
|
||||
get_cookie_header(request->server->name, request->path, &cookies);
|
||||
HTTP_HttpAddRequestHeadersW(request, cookies, strlenW(cookies), HTTP_ADDREQ_FLAG_REPLACE);
|
||||
|
||||
heap_free(cookies);
|
||||
}
|
||||
|
||||
|
@ -4815,29 +4766,24 @@ static DWORD open_http_connection(http_request_t *request, BOOL *reusing)
|
|||
INTERNET_STATUS_CONNECTED_TO_SERVER,
|
||||
request->server->addr_str, strlen(request->server->addr_str)+1);
|
||||
|
||||
if(is_https) {
|
||||
/* Note: we differ from Microsoft's WinINet here. they seem to have
|
||||
* a bug that causes no status callbacks to be sent when starting
|
||||
* a tunnel to a proxy server using the CONNECT verb. i believe our
|
||||
* behaviour to be more correct and to not cause any incompatibilities
|
||||
* because using a secure connection through a proxy server is a rare
|
||||
* case that would be hard for anyone to depend on */
|
||||
if(request->proxy)
|
||||
res = HTTP_SecureProxyConnect(request);
|
||||
if(res == ERROR_SUCCESS)
|
||||
res = NETCON_secure_connect(request->netconn, request->server);
|
||||
}
|
||||
|
||||
if(res != ERROR_SUCCESS) {
|
||||
http_release_netconn(request, FALSE);
|
||||
return res;
|
||||
}
|
||||
|
||||
*reusing = FALSE;
|
||||
TRACE("Created connection to %s: %p\n", debugstr_w(request->server->name), netconn);
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static char *build_ascii_request( const WCHAR *str, void *data, DWORD data_len, DWORD *out_len )
|
||||
{
|
||||
int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
|
||||
char *ret;
|
||||
|
||||
if (!(ret = heap_alloc( len + data_len ))) return NULL;
|
||||
WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
|
||||
if (data_len) memcpy( ret + len - 1, data, data_len );
|
||||
*out_len = len + data_len - 1;
|
||||
ret[*out_len] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* HTTP_HttpSendRequestW (internal)
|
||||
*
|
||||
|
@ -4852,13 +4798,11 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
|
|||
DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength,
|
||||
DWORD dwContentLength, BOOL bEndRequest)
|
||||
{
|
||||
INT cnt;
|
||||
BOOL redirected = FALSE;
|
||||
LPWSTR requestString = NULL;
|
||||
INT responseLen;
|
||||
BOOL loop_next;
|
||||
static const WCHAR szContentLength[] =
|
||||
{ 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0 };
|
||||
BOOL redirected = FALSE, secure_proxy_connect = FALSE, loop_next;
|
||||
LPWSTR requestString = NULL;
|
||||
INT responseLen, cnt;
|
||||
WCHAR contentLengthStr[sizeof szContentLength/2 /* includes \r\n */ + 20 /* int */ ];
|
||||
DWORD res;
|
||||
|
||||
|
@ -4873,7 +4817,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
|
|||
if (dwContentLength || strcmpW(request->verb, szGET))
|
||||
{
|
||||
sprintfW(contentLengthStr, szContentLength, dwContentLength);
|
||||
HTTP_HttpAddRequestHeadersW(request, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_REPLACE);
|
||||
HTTP_HttpAddRequestHeadersW(request, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
|
||||
request->bytesToWrite = dwContentLength;
|
||||
}
|
||||
if (request->session->appInfo->agent)
|
||||
|
@ -4907,7 +4851,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
|
|||
|
||||
do
|
||||
{
|
||||
DWORD len;
|
||||
DWORD len, data_len = dwOptionalLength;
|
||||
BOOL reusing_connection;
|
||||
char *ascii_req;
|
||||
|
||||
|
@ -4935,7 +4879,31 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
|
|||
if (!(request->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES))
|
||||
HTTP_InsertCookies(request);
|
||||
|
||||
if (request->proxy)
|
||||
res = open_http_connection(request, &reusing_connection);
|
||||
if (res != ERROR_SUCCESS)
|
||||
break;
|
||||
|
||||
if (!reusing_connection && (request->hdr.dwFlags & INTERNET_FLAG_SECURE))
|
||||
{
|
||||
if (request->proxy) secure_proxy_connect = TRUE;
|
||||
else
|
||||
{
|
||||
res = NETCON_secure_connect(request->netconn, request->server);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
WARN("failed to upgrade to secure connection\n");
|
||||
http_release_netconn(request, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (secure_proxy_connect)
|
||||
{
|
||||
static const WCHAR connectW[] = {'C','O','N','N','E','C','T',0};
|
||||
const WCHAR *target = request->server->host_port;
|
||||
requestString = build_request_header(request, connectW, target, g_szHttp1_1, TRUE);
|
||||
}
|
||||
else if (request->proxy && !(request->hdr.dwFlags & INTERNET_FLAG_SECURE))
|
||||
{
|
||||
WCHAR *url = build_proxy_path_url(request);
|
||||
requestString = build_request_header(request, request->verb, url, request->version, TRUE);
|
||||
|
@ -4944,25 +4912,13 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
|
|||
else
|
||||
requestString = build_request_header(request, request->verb, request->path, request->version, TRUE);
|
||||
|
||||
|
||||
TRACE("Request header -> %s\n", debugstr_w(requestString) );
|
||||
|
||||
res = open_http_connection(request, &reusing_connection);
|
||||
if (res != ERROR_SUCCESS)
|
||||
break;
|
||||
|
||||
/* send the request as ASCII, tack on the optional data */
|
||||
if (!lpOptional || redirected)
|
||||
dwOptionalLength = 0;
|
||||
len = WideCharToMultiByte( CP_ACP, 0, requestString, -1,
|
||||
NULL, 0, NULL, NULL );
|
||||
ascii_req = heap_alloc(len + dwOptionalLength);
|
||||
WideCharToMultiByte( CP_ACP, 0, requestString, -1,
|
||||
ascii_req, len, NULL, NULL );
|
||||
if( lpOptional )
|
||||
memcpy( &ascii_req[len-1], lpOptional, dwOptionalLength );
|
||||
len = (len + dwOptionalLength - 1);
|
||||
ascii_req[len] = 0;
|
||||
if (!lpOptional || redirected || secure_proxy_connect)
|
||||
data_len = 0;
|
||||
|
||||
ascii_req = build_ascii_request( requestString, lpOptional, data_len, &len );
|
||||
TRACE("full request -> %s\n", debugstr_a(ascii_req) );
|
||||
|
||||
INTERNET_SendCallback(&request->hdr, request->hdr.dwContext,
|
||||
|
@ -4980,7 +4936,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
|
|||
continue;
|
||||
}
|
||||
|
||||
request->bytesWritten = dwOptionalLength;
|
||||
request->bytesWritten = data_len;
|
||||
|
||||
INTERNET_SendCallback(&request->hdr, request->hdr.dwContext,
|
||||
INTERNET_STATUS_REQUEST_SENT,
|
||||
|
@ -5117,6 +5073,25 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
|
|||
}
|
||||
}
|
||||
}
|
||||
if (secure_proxy_connect && request->status_code == HTTP_STATUS_OK)
|
||||
{
|
||||
int index;
|
||||
|
||||
res = NETCON_secure_connect(request->netconn, request->server);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
WARN("failed to upgrade to secure proxy connection\n");
|
||||
http_release_netconn( request, FALSE );
|
||||
break;
|
||||
}
|
||||
index = HTTP_GetCustomHeaderIndex(request, szProxy_Authorization, 0, TRUE);
|
||||
if (index != -1) HTTP_DeleteCustomHeader(request, index);
|
||||
destroy_authinfo(request->proxyAuthInfo);
|
||||
request->proxyAuthInfo = NULL;
|
||||
|
||||
secure_proxy_connect = FALSE;
|
||||
loop_next = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
res = ERROR_SUCCESS;
|
||||
|
|
|
@ -57,6 +57,8 @@ typedef struct
|
|||
DWORD proxyEnabled;
|
||||
LPWSTR proxy;
|
||||
LPWSTR proxyBypass;
|
||||
LPWSTR proxyUsername;
|
||||
LPWSTR proxyPassword;
|
||||
} proxyinfo_t;
|
||||
|
||||
static ULONG max_conns = 2, max_1_0_conns = 4;
|
||||
|
@ -245,9 +247,11 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES)
|
||||
return FALSE;
|
||||
|
||||
#ifndef __REACTOS__
|
||||
URLCacheContainers_CreateDefaults();
|
||||
#endif
|
||||
if(!init_urlcache())
|
||||
{
|
||||
TlsFree(g_dwTlsErrIndex);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WININET_hModule = hinstDLL;
|
||||
break;
|
||||
|
@ -279,6 +283,15 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* DllInstall (WININET.@)
|
||||
*/
|
||||
HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
|
||||
{
|
||||
FIXME("(%x %s): stub\n", bInstall, debugstr_w(cmdline));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* INTERNET_SaveProxySettings
|
||||
*
|
||||
|
@ -454,6 +467,8 @@ static void FreeProxyInfo( proxyinfo_t *lpwpi )
|
|||
{
|
||||
heap_free(lpwpi->proxy);
|
||||
heap_free(lpwpi->proxyBypass);
|
||||
heap_free(lpwpi->proxyUsername);
|
||||
heap_free(lpwpi->proxyPassword);
|
||||
}
|
||||
|
||||
static proxyinfo_t *global_proxy;
|
||||
|
@ -469,6 +484,50 @@ static void free_global_proxy( void )
|
|||
LeaveCriticalSection( &WININET_cs );
|
||||
}
|
||||
|
||||
static BOOL parse_proxy_url( proxyinfo_t *info, const WCHAR *url )
|
||||
{
|
||||
static const WCHAR fmt[] = {'%','s',':','%','u',0};
|
||||
WCHAR hostname[INTERNET_MAX_HOST_NAME_LENGTH] = {0};
|
||||
WCHAR username[INTERNET_MAX_USER_NAME_LENGTH] = {0};
|
||||
WCHAR password[INTERNET_MAX_PASSWORD_LENGTH] = {0};
|
||||
URL_COMPONENTSW uc;
|
||||
|
||||
memset( &uc, 0, sizeof(uc) );
|
||||
uc.dwStructSize = sizeof(uc);
|
||||
uc.lpszHostName = hostname;
|
||||
uc.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH;
|
||||
uc.lpszUserName = username;
|
||||
uc.dwUserNameLength = INTERNET_MAX_USER_NAME_LENGTH;
|
||||
uc.lpszPassword = password;
|
||||
uc.dwPasswordLength = INTERNET_MAX_PASSWORD_LENGTH;
|
||||
|
||||
if (!InternetCrackUrlW( url, 0, 0, &uc )) return FALSE;
|
||||
if (!hostname[0])
|
||||
{
|
||||
if (!(info->proxy = heap_strdupW( url ))) return FALSE;
|
||||
info->proxyUsername = NULL;
|
||||
info->proxyPassword = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
if (!(info->proxy = heap_alloc( (strlenW(hostname) + 12) * sizeof(WCHAR) ))) return FALSE;
|
||||
sprintfW( info->proxy, fmt, hostname, uc.nPort );
|
||||
|
||||
if (!username[0]) info->proxyUsername = NULL;
|
||||
else if (!(info->proxyUsername = heap_strdupW( username )))
|
||||
{
|
||||
heap_free( info->proxy );
|
||||
return FALSE;
|
||||
}
|
||||
if (!password[0]) info->proxyPassword = NULL;
|
||||
else if (!(info->proxyPassword = heap_strdupW( password )))
|
||||
{
|
||||
heap_free( info->proxyUsername );
|
||||
heap_free( info->proxy );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* INTERNET_LoadProxySettings
|
||||
*
|
||||
|
@ -488,6 +547,8 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
LPCSTR envproxy;
|
||||
LONG ret;
|
||||
|
||||
memset( lpwpi, 0, sizeof(*lpwpi) );
|
||||
|
||||
EnterCriticalSection( &WININET_cs );
|
||||
if (global_proxy)
|
||||
{
|
||||
|
@ -498,7 +559,10 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
LeaveCriticalSection( &WININET_cs );
|
||||
|
||||
if ((ret = RegOpenKeyW( HKEY_CURRENT_USER, szInternetSettings, &key )))
|
||||
{
|
||||
FreeProxyInfo( lpwpi );
|
||||
return ret;
|
||||
}
|
||||
|
||||
len = sizeof(DWORD);
|
||||
if (RegQueryValueExW( key, szProxyEnable, NULL, &type, (BYTE *)&lpwpi->proxyEnabled, &len ) || type != REG_DWORD)
|
||||
|
@ -506,6 +570,7 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
lpwpi->proxyEnabled = 0;
|
||||
if((ret = RegSetValueExW( key, szProxyEnable, 0, REG_DWORD, (BYTE *)&lpwpi->proxyEnabled, sizeof(DWORD) )))
|
||||
{
|
||||
FreeProxyInfo( lpwpi );
|
||||
RegCloseKey( key );
|
||||
return ret;
|
||||
}
|
||||
|
@ -513,8 +578,6 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
|
||||
if (!(envproxy = getenv( "http_proxy" )) || lpwpi->proxyEnabled)
|
||||
{
|
||||
TRACE("Proxy is enabled.\n");
|
||||
|
||||
/* figure out how much memory the proxy setting takes */
|
||||
if (!RegQueryValueExW( key, szProxyServer, NULL, &type, NULL, &len ) && len && (type == REG_SZ))
|
||||
{
|
||||
|
@ -524,6 +587,7 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
if (!(szProxy = heap_alloc(len)))
|
||||
{
|
||||
RegCloseKey( key );
|
||||
FreeProxyInfo( lpwpi );
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
RegQueryValueExW( key, szProxyServer, NULL, &type, (BYTE*)szProxy, &len );
|
||||
|
@ -535,17 +599,21 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
p += lstrlenW( szHttp );
|
||||
lstrcpyW( szProxy, p );
|
||||
}
|
||||
p = strchrW( szProxy, ' ' );
|
||||
p = strchrW( szProxy, ';' );
|
||||
if (p) *p = 0;
|
||||
|
||||
FreeProxyInfo( lpwpi );
|
||||
lpwpi->proxy = szProxy;
|
||||
lpwpi->proxyBypass = NULL;
|
||||
|
||||
TRACE("http proxy = %s\n", debugstr_w(lpwpi->proxy));
|
||||
TRACE("http proxy (from registry) = %s\n", debugstr_w(lpwpi->proxy));
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("No proxy server settings in registry.\n");
|
||||
FreeProxyInfo( lpwpi );
|
||||
lpwpi->proxy = NULL;
|
||||
lpwpi->proxyBypass = NULL;
|
||||
}
|
||||
}
|
||||
else if (envproxy)
|
||||
|
@ -554,18 +622,33 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
|
||||
len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 );
|
||||
if (!(envproxyW = heap_alloc(len * sizeof(WCHAR))))
|
||||
{
|
||||
RegCloseKey( key );
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len );
|
||||
|
||||
lpwpi->proxyEnabled = 1;
|
||||
lpwpi->proxy = envproxyW;
|
||||
|
||||
TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi->proxy));
|
||||
FreeProxyInfo( lpwpi );
|
||||
if (parse_proxy_url( lpwpi, envproxyW ))
|
||||
{
|
||||
TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi->proxy));
|
||||
lpwpi->proxyEnabled = 1;
|
||||
lpwpi->proxyBypass = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN("failed to parse http_proxy value %s\n", debugstr_w(envproxyW));
|
||||
lpwpi->proxyEnabled = 0;
|
||||
lpwpi->proxy = NULL;
|
||||
lpwpi->proxyBypass = NULL;
|
||||
}
|
||||
heap_free( envproxyW );
|
||||
}
|
||||
|
||||
lpwpi->proxyBypass = NULL;
|
||||
if (lpwpi->proxyEnabled)
|
||||
{
|
||||
TRACE("Proxy is enabled.\n");
|
||||
|
||||
if (!(envproxy = getenv( "no_proxy" )))
|
||||
{
|
||||
/* figure out how much memory the proxy setting takes */
|
||||
|
@ -580,32 +663,40 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
}
|
||||
RegQueryValueExW( key, szProxyOverride, NULL, &type, (BYTE*)szProxy, &len );
|
||||
|
||||
heap_free( lpwpi->proxyBypass );
|
||||
lpwpi->proxyBypass = szProxy;
|
||||
|
||||
TRACE("http proxy bypass = %s\n", debugstr_w(lpwpi->proxyBypass));
|
||||
TRACE("http proxy bypass (from registry) = %s\n", debugstr_w(lpwpi->proxyBypass));
|
||||
}
|
||||
else
|
||||
{
|
||||
heap_free( lpwpi->proxyBypass );
|
||||
lpwpi->proxyBypass = NULL;
|
||||
|
||||
TRACE("No proxy bypass server settings in registry.\n");
|
||||
}
|
||||
}
|
||||
else if (envproxy)
|
||||
else
|
||||
{
|
||||
WCHAR *envproxyW;
|
||||
|
||||
len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 );
|
||||
if (!(envproxyW = heap_alloc(len * sizeof(WCHAR))))
|
||||
{
|
||||
RegCloseKey( key );
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len );
|
||||
|
||||
heap_free( lpwpi->proxyBypass );
|
||||
lpwpi->proxyBypass = envproxyW;
|
||||
|
||||
TRACE("http proxy bypass (from environment) = %s\n", debugstr_w(lpwpi->proxyBypass));
|
||||
}
|
||||
}
|
||||
else TRACE("Proxy is disabled.\n");
|
||||
|
||||
RegCloseKey( key );
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -614,56 +705,21 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
|
|||
*/
|
||||
static BOOL INTERNET_ConfigureProxy( appinfo_t *lpwai )
|
||||
{
|
||||
proxyinfo_t wpi = {0};
|
||||
proxyinfo_t wpi;
|
||||
|
||||
if (INTERNET_LoadProxySettings( &wpi ))
|
||||
return FALSE;
|
||||
|
||||
if (wpi.proxyEnabled)
|
||||
{
|
||||
WCHAR proxyurl[INTERNET_MAX_URL_LENGTH];
|
||||
WCHAR username[INTERNET_MAX_USER_NAME_LENGTH];
|
||||
WCHAR password[INTERNET_MAX_PASSWORD_LENGTH];
|
||||
WCHAR hostname[INTERNET_MAX_HOST_NAME_LENGTH];
|
||||
URL_COMPONENTSW UrlComponents;
|
||||
TRACE("http proxy = %s bypass = %s\n", debugstr_w(lpwai->proxy), debugstr_w(lpwai->proxyBypass));
|
||||
|
||||
UrlComponents.dwStructSize = sizeof UrlComponents;
|
||||
UrlComponents.dwSchemeLength = 0;
|
||||
UrlComponents.lpszHostName = hostname;
|
||||
UrlComponents.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH;
|
||||
UrlComponents.lpszUserName = username;
|
||||
UrlComponents.dwUserNameLength = INTERNET_MAX_USER_NAME_LENGTH;
|
||||
UrlComponents.lpszPassword = password;
|
||||
UrlComponents.dwPasswordLength = INTERNET_MAX_PASSWORD_LENGTH;
|
||||
UrlComponents.dwUrlPathLength = 0;
|
||||
UrlComponents.dwExtraInfoLength = 0;
|
||||
|
||||
if(InternetCrackUrlW(wpi.proxy, 0, 0, &UrlComponents))
|
||||
{
|
||||
static const WCHAR szFormat[] = { 'h','t','t','p',':','/','/','%','s',':','%','u',0 };
|
||||
|
||||
if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER)
|
||||
UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
sprintfW(proxyurl, szFormat, hostname, UrlComponents.nPort);
|
||||
|
||||
lpwai->accessType = INTERNET_OPEN_TYPE_PROXY;
|
||||
lpwai->proxy = heap_strdupW(proxyurl);
|
||||
lpwai->proxyBypass = heap_strdupW(wpi.proxyBypass);
|
||||
if (UrlComponents.dwUserNameLength)
|
||||
{
|
||||
lpwai->proxyUsername = heap_strdupW(UrlComponents.lpszUserName);
|
||||
lpwai->proxyPassword = heap_strdupW(UrlComponents.lpszPassword);
|
||||
}
|
||||
|
||||
TRACE("http proxy = %s bypass = %s\n", debugstr_w(lpwai->proxy), debugstr_w(lpwai->proxyBypass));
|
||||
FreeProxyInfo(&wpi);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Failed to parse proxy: %s\n", debugstr_w(wpi.proxy));
|
||||
lpwai->proxy = NULL;
|
||||
}
|
||||
lpwai->accessType = INTERNET_OPEN_TYPE_PROXY;
|
||||
lpwai->proxy = wpi.proxy;
|
||||
lpwai->proxyBypass = wpi.proxyBypass;
|
||||
lpwai->proxyUsername = wpi.proxyUsername;
|
||||
lpwai->proxyPassword = wpi.proxyPassword;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
lpwai->accessType = INTERNET_OPEN_TYPE_DIRECT;
|
||||
|
@ -1198,11 +1254,10 @@ BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectio
|
|||
rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName, dwNameLen,
|
||||
dwReserved);
|
||||
if (rc && lpwszConnectionName)
|
||||
{
|
||||
WideCharToMultiByte(CP_ACP,0,lpwszConnectionName,-1,lpszConnectionName,
|
||||
dwNameLen, NULL, NULL);
|
||||
heap_free(lpwszConnectionName);
|
||||
}
|
||||
|
||||
heap_free(lpwszConnectionName);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -2008,7 +2063,7 @@ BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
|
|||
{
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl), lpszBuffer,
|
||||
TRACE("(%s, %p, %p, 0x%08x) buffer length: %d\n", debugstr_a(lpszUrl), lpszBuffer,
|
||||
lpdwBufferLength, dwFlags, lpdwBufferLength ? *lpdwBufferLength : -1);
|
||||
|
||||
dwFlags = convert_url_canonicalization_flags(dwFlags);
|
||||
|
@ -2034,7 +2089,7 @@ BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
|
|||
{
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl), lpszBuffer,
|
||||
TRACE("(%s, %p, %p, 0x%08x) buffer length: %d\n", debugstr_w(lpszUrl), lpszBuffer,
|
||||
lpdwBufferLength, dwFlags, lpdwBufferLength ? *lpdwBufferLength : -1);
|
||||
|
||||
dwFlags = convert_url_canonicalization_flags(dwFlags);
|
||||
|
@ -2302,6 +2357,34 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
|
|||
return res == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOL get_proxy_autoconfig_url( char *buf, DWORD buflen )
|
||||
{
|
||||
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
|
||||
CFDictionaryRef settings = CFNetworkCopySystemProxySettings();
|
||||
const void *ref;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
if (!settings) return FALSE;
|
||||
|
||||
if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString )))
|
||||
{
|
||||
CFRelease( settings );
|
||||
return FALSE;
|
||||
}
|
||||
if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII ))
|
||||
{
|
||||
TRACE( "returning %s\n", debugstr_a(buf) );
|
||||
ret = TRUE;
|
||||
}
|
||||
CFRelease( settings );
|
||||
return ret;
|
||||
#else
|
||||
FIXME( "no support on this platform\n" );
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL unicode)
|
||||
{
|
||||
/* FIXME: This function currently handles more options than it should. Options requiring
|
||||
|
@ -2385,16 +2468,20 @@ static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL u
|
|||
}
|
||||
|
||||
case INTERNET_OPTION_PER_CONNECTION_OPTION: {
|
||||
char url[INTERNET_MAX_URL_LENGTH + 1];
|
||||
INTERNET_PER_CONN_OPTION_LISTW *con = buffer;
|
||||
INTERNET_PER_CONN_OPTION_LISTA *conA = buffer;
|
||||
DWORD res = ERROR_SUCCESS, i;
|
||||
proxyinfo_t pi;
|
||||
BOOL have_url;
|
||||
LONG ret;
|
||||
|
||||
TRACE("Getting global proxy info\n");
|
||||
if((ret = INTERNET_LoadProxySettings(&pi)))
|
||||
return ret;
|
||||
|
||||
have_url = get_proxy_autoconfig_url(url, sizeof(url));
|
||||
|
||||
FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
|
||||
|
||||
if (*size < sizeof(INTERNET_PER_CONN_OPTION_LISTW)) {
|
||||
|
@ -2412,6 +2499,9 @@ static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL u
|
|||
optionW->Value.dwValue = PROXY_TYPE_PROXY;
|
||||
else
|
||||
optionW->Value.dwValue = PROXY_TYPE_DIRECT;
|
||||
if (have_url)
|
||||
/* native includes PROXY_TYPE_DIRECT even if PROXY_TYPE_PROXY is set */
|
||||
optionW->Value.dwValue |= PROXY_TYPE_DIRECT|PROXY_TYPE_AUTO_PROXY_URL;
|
||||
break;
|
||||
|
||||
case INTERNET_PER_CONN_PROXY_SERVER:
|
||||
|
@ -2429,7 +2519,18 @@ static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL u
|
|||
break;
|
||||
|
||||
case INTERNET_PER_CONN_AUTOCONFIG_URL:
|
||||
if (!have_url)
|
||||
optionW->Value.pszValue = NULL;
|
||||
else if (unicode)
|
||||
optionW->Value.pszValue = heap_strdupAtoW(url);
|
||||
else
|
||||
optionA->Value.pszValue = heap_strdupA(url);
|
||||
break;
|
||||
|
||||
case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS:
|
||||
optionW->Value.dwValue = AUTO_PROXY_FLAG_ALWAYS_DETECT;
|
||||
break;
|
||||
|
||||
case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
|
||||
case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS:
|
||||
case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME:
|
||||
|
@ -2848,7 +2949,7 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
|
|||
unsigned int i;
|
||||
proxyinfo_t pi;
|
||||
|
||||
INTERNET_LoadProxySettings(&pi);
|
||||
if (INTERNET_LoadProxySettings(&pi)) return FALSE;
|
||||
|
||||
for (i = 0; i < con->dwOptionCount; i++) {
|
||||
INTERNET_PER_CONN_OPTIONW *option = con->pOptions + i;
|
||||
|
@ -3772,7 +3873,7 @@ LPSTR INTERNET_GetResponseBuffer(void)
|
|||
|
||||
LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
|
||||
{
|
||||
// ReactOS: use select instead of poll
|
||||
/* ReactOS: use select instead of poll */
|
||||
fd_set infd;
|
||||
struct timeval tv;
|
||||
BOOL bSuccess = FALSE;
|
||||
|
@ -3790,7 +3891,7 @@ LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
|
|||
{
|
||||
if (select(0, &infd, NULL, NULL, &tv) > 0)
|
||||
{
|
||||
if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
|
||||
if (sock_recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
|
||||
goto lend;
|
||||
|
|
|
@ -458,8 +458,8 @@ DWORD HTTP_Connect(appinfo_t*,LPCWSTR,
|
|||
BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
|
||||
struct sockaddr *psa, socklen_t *sa_len) DECLSPEC_HIDDEN;
|
||||
|
||||
DWORD get_cookie(const WCHAR*,const WCHAR*,WCHAR*,DWORD*) DECLSPEC_HIDDEN;
|
||||
BOOL set_cookie(const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
|
||||
DWORD get_cookie_header(const WCHAR*,const WCHAR*,WCHAR**) DECLSPEC_HIDDEN;
|
||||
DWORD set_cookie(const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*,DWORD) DECLSPEC_HIDDEN;
|
||||
|
||||
void INTERNET_SetLastError(DWORD dwError) DECLSPEC_HIDDEN;
|
||||
DWORD INTERNET_GetLastError(void) DECLSPEC_HIDDEN;
|
||||
|
@ -497,6 +497,7 @@ DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC
|
|||
#ifndef __REACTOS__
|
||||
int sock_get_error(int) DECLSPEC_HIDDEN;
|
||||
#else
|
||||
|
||||
#define sock_get_error(x) WSAGetLastError()
|
||||
const char *inet_ntop(int, const void *, char *, socklen_t);
|
||||
|
||||
|
@ -517,7 +518,11 @@ static inline int unix_getsockopt(int socket, int level, int option_name, void *
|
|||
return getsockopt(socket, level, option_name, option_value, option_len);
|
||||
}
|
||||
#define getsockopt unix_getsockopt
|
||||
#endif
|
||||
|
||||
#endif /* !__REACTOS__ */
|
||||
|
||||
int sock_send(int fd, const void *msg, size_t len, int flags) DECLSPEC_HIDDEN;
|
||||
int sock_recv(int fd, void *msg, size_t len, int flags) DECLSPEC_HIDDEN;
|
||||
|
||||
server_t *get_server(const WCHAR*,INTERNET_PORT,BOOL,BOOL);
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD t
|
|||
if(result == -1)
|
||||
{
|
||||
if (sock_get_error(errno) == WSAEINPROGRESS) {
|
||||
// ReactOS: use select instead of poll
|
||||
/* ReactOS: use select instead of poll */
|
||||
fd_set outfd;
|
||||
struct timeval tv;
|
||||
int res;
|
||||
|
@ -280,6 +280,7 @@ static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD t
|
|||
if (!res)
|
||||
{
|
||||
closesocket(netconn->socket);
|
||||
netconn->socket = -1;
|
||||
return ERROR_INTERNET_CANNOT_CONNECT;
|
||||
}
|
||||
else if (res > 0)
|
||||
|
@ -449,7 +450,29 @@ int sock_get_error( int err )
|
|||
#endif
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
#endif /* !__REACTOS__ */
|
||||
|
||||
int sock_send(int fd, const void *msg, size_t len, int flags)
|
||||
{
|
||||
int ret;
|
||||
do
|
||||
{
|
||||
ret = send(fd, msg, len, flags);
|
||||
}
|
||||
while(ret == -1 && errno == EINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sock_recv(int fd, void *msg, size_t len, int flags)
|
||||
{
|
||||
int ret;
|
||||
do
|
||||
{
|
||||
ret = recv(fd, msg, len, flags);
|
||||
}
|
||||
while(ret == -1 && errno == EINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void set_socket_blocking(int socket, blocking_mode_t mode)
|
||||
{
|
||||
|
@ -501,7 +524,7 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode
|
|||
|
||||
TRACE("sending %u bytes\n", out_buf.cbBuffer);
|
||||
|
||||
size = send(connection->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
|
||||
size = sock_send(connection->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
|
||||
if(size != out_buf.cbBuffer) {
|
||||
ERR("send failed\n");
|
||||
status = ERROR_INTERNET_SECURITY_CHANNEL_ERROR;
|
||||
|
@ -540,7 +563,7 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode
|
|||
read_buf_size += 1024;
|
||||
}
|
||||
|
||||
size = recv(connection->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0);
|
||||
size = sock_recv(connection->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0);
|
||||
if(size < 1) {
|
||||
WARN("recv error\n");
|
||||
res = ERROR_INTERNET_SECURITY_CHANNEL_ERROR;
|
||||
|
@ -591,6 +614,8 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode
|
|||
}
|
||||
}
|
||||
|
||||
heap_free(read_buf);
|
||||
|
||||
if(status != SEC_E_OK || res != ERROR_SUCCESS) {
|
||||
WARN("Failed to establish SSL connection: %08x (%u)\n", status, res);
|
||||
heap_free(connection->ssl_buf);
|
||||
|
@ -671,7 +696,7 @@ static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if(send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) {
|
||||
if(sock_send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) {
|
||||
WARN("send failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -689,7 +714,7 @@ DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags,
|
|||
{
|
||||
if(!connection->secure)
|
||||
{
|
||||
*sent = send(connection->socket, msg, len, flags);
|
||||
*sent = sock_send(connection->socket, msg, len, flags);
|
||||
if (*sent == -1)
|
||||
return sock_get_error(errno);
|
||||
return ERROR_SUCCESS;
|
||||
|
@ -741,7 +766,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, blocking
|
|||
|
||||
tmp_mode = buf_len ? BLOCKING_DISALLOW : mode;
|
||||
set_socket_blocking(conn->socket, tmp_mode);
|
||||
size = recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, tmp_mode == BLOCKING_ALLOW ? 0 : WINE_MSG_DONTWAIT);
|
||||
size = sock_recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, tmp_mode == BLOCKING_ALLOW ? 0 : WINE_MSG_DONTWAIT);
|
||||
if(size < 0) {
|
||||
if(!buf_len) {
|
||||
if(errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
|
@ -782,7 +807,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, blocking
|
|||
assert(buf_len < ssl_buf_size);
|
||||
|
||||
set_socket_blocking(conn->socket, mode);
|
||||
size = recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, mode == BLOCKING_ALLOW ? 0 : WINE_MSG_DONTWAIT);
|
||||
size = sock_recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, mode == BLOCKING_ALLOW ? 0 : WINE_MSG_DONTWAIT);
|
||||
if(size < 1) {
|
||||
if(size < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
|
||||
TRACE("would block\n");
|
||||
|
@ -866,7 +891,7 @@ DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, blocking_mode_t
|
|||
}
|
||||
|
||||
set_socket_blocking(connection->socket, mode);
|
||||
*recvd = recv(connection->socket, buf, len, flags);
|
||||
*recvd = sock_recv(connection->socket, buf, len, flags);
|
||||
return *recvd == -1 ? sock_get_error(errno) : ERROR_SUCCESS;
|
||||
}
|
||||
else
|
||||
|
@ -954,7 +979,7 @@ BOOL NETCON_is_alive(netconn_t *netconn)
|
|||
ssize_t len;
|
||||
BYTE b;
|
||||
|
||||
len = recv(netconn->socket, &b, 1, MSG_PEEK|MSG_DONTWAIT);
|
||||
len = sock_recv(netconn->socket, &b, 1, MSG_PEEK|MSG_DONTWAIT);
|
||||
return len == 1 || (len == -1 && errno == EWOULDBLOCK);
|
||||
#elif defined(__MINGW32__) || defined(_MSC_VER)
|
||||
ULONG mode;
|
||||
|
@ -965,7 +990,7 @@ BOOL NETCON_is_alive(netconn_t *netconn)
|
|||
if(!ioctlsocket(netconn->socket, FIONBIO, &mode))
|
||||
return FALSE;
|
||||
|
||||
len = recv(netconn->socket, &b, 1, MSG_PEEK);
|
||||
len = sock_recv(netconn->socket, &b, 1, MSG_PEEK);
|
||||
|
||||
mode = 0;
|
||||
if(!ioctlsocket(netconn->socket, FIONBIO, &mode))
|
||||
|
|
|
@ -179,7 +179,7 @@ typedef struct
|
|||
|
||||
/* List of all containers available */
|
||||
static struct list UrlContainers = LIST_INIT(UrlContainers);
|
||||
// ReactOS r54992
|
||||
/* ReactOS r54992 */
|
||||
BOOL bDefaultContainersAdded = FALSE;
|
||||
|
||||
static inline char *heap_strdupWtoUTF8(LPCWSTR str)
|
||||
|
@ -731,7 +731,7 @@ static void cache_containers_init(void)
|
|||
static const WCHAR UrlSuffix[] = {'C','o','n','t','e','n','t','.','I','E','5',0};
|
||||
static const WCHAR HistorySuffix[] = {'H','i','s','t','o','r','y','.','I','E','5',0};
|
||||
static const WCHAR CookieSuffix[] = {0};
|
||||
// ReactOS r50916
|
||||
/* ReactOS r50916 */
|
||||
static const WCHAR UserProfile[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
|
||||
static const struct
|
||||
{
|
||||
|
@ -747,7 +747,7 @@ static void cache_containers_init(void)
|
|||
};
|
||||
DWORD i;
|
||||
|
||||
// ReactOS r50916
|
||||
/* ReactOS r50916 */
|
||||
if (GetEnvironmentVariableW(UserProfile, NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
|
||||
{
|
||||
TRACE("Environment variable 'USERPROFILE' does not exist!\n");
|
||||
|
@ -823,7 +823,7 @@ static DWORD cache_containers_find(const char *url, cache_container **ret)
|
|||
if(!url)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
// ReactOS r54992
|
||||
/* ReactOS r54992 */
|
||||
if (!bDefaultContainersAdded)
|
||||
cache_containers_init();
|
||||
|
||||
|
@ -853,7 +853,7 @@ static BOOL cache_containers_enum(char *search_pattern, DWORD index, cache_conta
|
|||
if (search_pattern && index > 0)
|
||||
return FALSE;
|
||||
|
||||
// ReactOS r54992
|
||||
/* ReactOS r54992 */
|
||||
if (!bDefaultContainersAdded)
|
||||
cache_containers_init();
|
||||
|
||||
|
@ -1477,7 +1477,7 @@ static DWORD urlcache_hash_key(LPCSTR lpszKey)
|
|||
for (i = 0; i < sizeof(key) / sizeof(key[0]); i++)
|
||||
key[i] = lookupTable[(*lpszKey + i) & 0xFF];
|
||||
|
||||
for (lpszKey++; *lpszKey && ((lpszKey[0] != '/') || (lpszKey[1] != 0)); lpszKey++)
|
||||
for (lpszKey++; *lpszKey; lpszKey++)
|
||||
{
|
||||
for (i = 0; i < sizeof(key) / sizeof(key[0]); i++)
|
||||
key[i] = lookupTable[*lpszKey ^ key[i]];
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* WinInet
|
||||
*
|
||||
* Copyright (c) 2000 Patrik Stridvall
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "internet.h"
|
||||
|
||||
/***********************************************************************
|
||||
* DllInstall (WININET.@)
|
||||
*/
|
||||
HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
|
||||
{
|
||||
FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
|
||||
debugstr_w(cmdline));
|
||||
|
||||
return S_OK;
|
||||
}
|
|
@ -211,7 +211,7 @@ reactos/dll/win32/windowscodecsext # Synced to Wine-1.7.17
|
|||
reactos/dll/win32/winemp3.acm # Synced to Wine-1.7.17
|
||||
reactos/dll/win32/wing32 # Out of sync
|
||||
reactos/dll/win32/winhttp # Synced to Wine-1.7.27
|
||||
reactos/dll/win32/wininet # Synced to Wine-1.7.17
|
||||
reactos/dll/win32/wininet # Synced to Wine-1.7.27
|
||||
reactos/dll/win32/winmm # Forked at Wine-20050628
|
||||
reactos/dll/win32/winmm/midimap # Forked at Wine-20050628
|
||||
reactos/dll/win32/winmm/wavemap # Forked at Wine-20050628
|
||||
|
|
Loading…
Reference in a new issue