Jacek Caban : urlmon: Correctly handle empty files.
Alexandre Julliard
julliard at winehq.org
Thu Jun 9 11:47:39 CDT 2011
Module: wine
Branch: master
Commit: 66917c61d6e61c97941ff0f1d09b3855fcb1fd9e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=66917c61d6e61c97941ff0f1d09b3855fcb1fd9e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Jun 9 14:03:13 2011 +0200
urlmon: Correctly handle empty files.
---
dlls/urlmon/protocol.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/dlls/urlmon/protocol.c b/dlls/urlmon/protocol.c
index 326564b..94801ae 100644
--- a/dlls/urlmon/protocol.c
+++ b/dlls/urlmon/protocol.c
@@ -286,6 +286,7 @@ HRESULT protocol_start(Protocol *protocol, IInternetProtocol *prot, IUri *uri,
HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data)
{
+ BOOL is_start;
HRESULT hres;
if (!data) {
@@ -293,6 +294,8 @@ HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data)
return S_OK;
}
+ is_start = data->pData == (LPVOID)BINDSTATUS_DOWNLOADINGDATA;
+
if(!protocol->request) {
WARN("Expected request to be non-NULL\n");
return S_OK;
@@ -312,7 +315,7 @@ HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data)
if(protocol->post_stream)
return write_post_stream(protocol);
- if(data->pData == (LPVOID)BINDSTATUS_DOWNLOADINGDATA) {
+ if(is_start) {
hres = protocol->vtbl->start_downloading(protocol);
if(FAILED(hres)) {
protocol_close_connection(protocol);
@@ -344,6 +347,16 @@ HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data)
protocol->flags &= ~FLAG_REQUEST_COMPLETE;
res = InternetQueryDataAvailable(protocol->request, &protocol->available_bytes, 0, 0);
if(res) {
+ if(!protocol->available_bytes) {
+ if(is_start) {
+ TRACE("empty file\n");
+ all_data_read(protocol);
+ }else {
+ WARN("unexpected end of file?\n");
+ report_result(protocol, INET_E_DOWNLOAD_FAILURE);
+ }
+ return S_OK;
+ }
protocol->flags |= FLAG_REQUEST_COMPLETE;
report_data(protocol);
}else if(GetLastError() != ERROR_IO_PENDING) {
More information about the wine-cvs
mailing list