winhttp: Use an offset instead of a pointer for the write position.

This commit is contained in:
Hans Leidekker 2011-07-23 18:14:52 +02:00 committed by Alexandre Julliard
parent f87745d497
commit 73646d3529
1 changed files with 7 additions and 7 deletions

View File

@ -2157,7 +2157,7 @@ struct winhttp_request
HANDLE wait; HANDLE wait;
HANDLE cancel; HANDLE cancel;
char *buffer; char *buffer;
char *ptr; DWORD offset;
DWORD bytes_available; DWORD bytes_available;
DWORD bytes_read; DWORD bytes_read;
LONG resolve_timeout; LONG resolve_timeout;
@ -2624,7 +2624,6 @@ static DWORD request_read_body( struct winhttp_request *request, DWORD timeout )
if (!(request->buffer = heap_alloc( buflen ))) return E_OUTOFMEMORY; if (!(request->buffer = heap_alloc( buflen ))) return E_OUTOFMEMORY;
size = total_bytes_read = 0; size = total_bytes_read = 0;
request->ptr = request->buffer;
do do
{ {
wait_set_status_callback( request, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE ); wait_set_status_callback( request, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE );
@ -2648,14 +2647,15 @@ static DWORD request_read_body( struct winhttp_request *request, DWORD timeout )
request->buffer = tmp; request->buffer = tmp;
} }
wait_set_status_callback( request, WINHTTP_CALLBACK_STATUS_READ_COMPLETE ); wait_set_status_callback( request, WINHTTP_CALLBACK_STATUS_READ_COMPLETE );
if (!WinHttpReadData( request->hrequest, request->ptr, request->bytes_available, &request->bytes_read )) if (!WinHttpReadData( request->hrequest, request->buffer + request->offset,
request->bytes_available, &request->bytes_read ))
{ {
err = GetLastError(); err = GetLastError();
goto error; goto error;
} }
wait_for_completion( request, timeout ); wait_for_completion( request, timeout );
total_bytes_read += request->bytes_read; total_bytes_read += request->bytes_read;
request->ptr += request->bytes_read; request->offset += request->bytes_read;
} while (request->bytes_read); } while (request->bytes_read);
request->state = REQUEST_STATE_BODY_RECEIVED; request->state = REQUEST_STATE_BODY_RECEIVED;
@ -2713,9 +2713,9 @@ static HRESULT WINAPI winhttp_request_get_ResponseText(
if ((err = request_read_body( request, INFINITE ))) return HRESULT_FROM_WIN32( err ); if ((err = request_read_body( request, INFINITE ))) return HRESULT_FROM_WIN32( err );
if ((err = request_get_codepage( request, &codepage ))) return HRESULT_FROM_WIN32( err ); if ((err = request_get_codepage( request, &codepage ))) return HRESULT_FROM_WIN32( err );
len = MultiByteToWideChar( codepage, 0, request->buffer, request->ptr - request->buffer, NULL, 0 ); len = MultiByteToWideChar( codepage, 0, request->buffer, request->offset, NULL, 0 );
if (!(*body = SysAllocStringLen( NULL, len ))) return E_OUTOFMEMORY; if (!(*body = SysAllocStringLen( NULL, len ))) return E_OUTOFMEMORY;
MultiByteToWideChar( codepage, 0, request->buffer, request->ptr - request->buffer, *body, len ); MultiByteToWideChar( codepage, 0, request->buffer, request->offset, *body, len );
(*body)[len] = 0; (*body)[len] = 0;
return S_OK; return S_OK;
} }
@ -2788,7 +2788,7 @@ static HRESULT WINAPI winhttp_request_Abort(
request->wait = NULL; request->wait = NULL;
request->cancel = NULL; request->cancel = NULL;
request->buffer = NULL; request->buffer = NULL;
request->ptr = NULL; request->offset = 0;
request->bytes_available = 0; request->bytes_available = 0;
request->bytes_read = 0; request->bytes_read = 0;
return S_OK; return S_OK;