The GetData method transfers data from the server to the
local system, storing it in the specified buffer . This method will
cause the current thread to block until the file transfer completes,
a timeout occurs or the transfer is canceled. During the transfer,
the OnProgress event will fire periodically, enabling the
application to update any user interface objects such as a progress
bar.
When encountering a server error during a request, the GetData
method normally returns an error code, and no data is copied into the
caller-provided buffer. The error code reflects the general cause of the
failure, allowing the application to handle this error condition appropriately.
Additionally, servers may provide further details about the failure,
such as XML or JSON formatted data containing specific error codes or
diagnostic messages.
To capture this error information, you can utilize the
httpTransferErrorData option. When this option is enabled, the
behavior of GetData changes; it does not return an error code
for server error statuses. Instead, any error data provided in the
server's response, regardless of its format, is copied into the buffer
provided by the caller. If this option is used, your application
should check the ResultCode property to obtain the
HTTP status code returned by the server. This will enable you to
determine if the operation was successful.
Specifying the httpTransferCompress option does not guarantee
that the data returned by the server will actually be compressed, it
only informs the server that the client is willing to accept compressed
data. Whether or not a particular resource is compressed depends on the
server configuration, and the server may decide to only compress certain
types of resources, such as text files.
If compression has been enabled and the server returns compressed
data, it will be automatically expanded before being returned to the
caller. If the application is using the OnProgress event to
determine the amount of data being returned by the server, it is
important to keep in mind that the values reflect the size of the
compressed data.