wininet: Directly return error status from NETCON_recv.

This commit is contained in:
Jacek Caban 2009-11-30 19:59:40 +01:00 committed by Alexandre Julliard
parent 1563c137fa
commit 358e7b7c8a
3 changed files with 14 additions and 15 deletions

View File

@ -2018,6 +2018,7 @@ static DWORD HTTPREQ_SetOption(object_header_t *hdr, DWORD option, void *buffer,
/* read some more data into the read buffer (the read section must be held) */ /* read some more data into the read buffer (the read section must be held) */
static BOOL read_more_data( http_request_t *req, int maxlen ) static BOOL read_more_data( http_request_t *req, int maxlen )
{ {
DWORD res;
int len; int len;
if (req->read_pos) if (req->read_pos)
@ -2030,9 +2031,12 @@ static BOOL read_more_data( http_request_t *req, int maxlen )
if (maxlen == -1) maxlen = sizeof(req->read_buf); if (maxlen == -1) maxlen = sizeof(req->read_buf);
if(!NETCON_recv( &req->netConnection, req->read_buf + req->read_size, res = NETCON_recv( &req->netConnection, req->read_buf + req->read_size,
maxlen - req->read_size, 0, &len )) maxlen - req->read_size, 0, &len );
if(res != ERROR_SUCCESS) {
INTERNET_SetLastError(res);
return FALSE; return FALSE;
}
req->read_size += len; req->read_size += len;
return TRUE; return TRUE;
@ -2304,7 +2308,7 @@ static DWORD HTTPREQ_Read(http_request_t *req, void *buffer, DWORD size, DWORD *
if (size > bytes_read && (!bytes_read || sync)) { if (size > bytes_read && (!bytes_read || sync)) {
if (NETCON_recv( &req->netConnection, (char *)buffer + bytes_read, size - bytes_read, if (NETCON_recv( &req->netConnection, (char *)buffer + bytes_read, size - bytes_read,
sync ? MSG_WAITALL : 0, &len)) sync ? MSG_WAITALL : 0, &len) == ERROR_SUCCESS)
bytes_read += len; bytes_read += len;
/* always return success, even if the network layer returns an error */ /* always return success, even if the network layer returns an error */
} }

View File

@ -438,7 +438,7 @@ DWORD NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *s
DWORD NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname); DWORD NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
DWORD NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags, DWORD NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
int *sent /* out */); int *sent /* out */);
BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags, DWORD NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
int *recvd /* out */); int *recvd /* out */);
BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available); BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection); LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);

View File

@ -584,30 +584,25 @@ DWORD NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len
* Basically calls 'recv()' unless we should use SSL * Basically calls 'recv()' unless we should use SSL
* number of chars received is put in *recvd * number of chars received is put in *recvd
*/ */
BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags, DWORD NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
int *recvd /* out */) int *recvd /* out */)
{ {
*recvd = 0; *recvd = 0;
if (!NETCON_connected(connection)) return FALSE; if (!NETCON_connected(connection)) return ERROR_INTERNET_CONNECTION_ABORTED;
if (!len) if (!len)
return TRUE; return ERROR_SUCCESS;
if (!connection->useSSL) if (!connection->useSSL)
{ {
*recvd = recv(connection->socketFD, buf, len, flags); *recvd = recv(connection->socketFD, buf, len, flags);
if (*recvd == -1) return *recvd == -1 ? sock_get_error(errno) : ERROR_SUCCESS;
{
INTERNET_SetLastError(sock_get_error(errno));
return FALSE;
}
return TRUE;
} }
else else
{ {
#ifdef SONAME_LIBSSL #ifdef SONAME_LIBSSL
*recvd = pSSL_read(connection->ssl_s, buf, len); *recvd = pSSL_read(connection->ssl_s, buf, len);
return *recvd > 0 || !len; return *recvd > 0 ? ERROR_SUCCESS : ERROR_INTERNET_CONNECTION_ABORTED;
#else #else
return FALSE; return ERROR_NOT_SUPPORTED;
#endif #endif
} }
} }