Callbacks
Response (HttpResponseMessage)
Contains the whole or partial response from the server based on the HttpCompletionOption
- If the HttpCompletionOption is set to AllResponseContent or there is no HttpCompletionOption the HttpResponseMessage callback will be raised once when the download completes
- If the HttpCompletionOption is set to StreamResponseContent the HttpResponseMessage callback will be raised perodically when DownloadBlockSize bytes of data have been downloaded or when all data has been read
- If an exception is raised it will be contained in the Exception property
HttpResponseMessage Properties
Property | Description |
---|---|
OriginalRequest | The core request object if additional information is required - might be null if an exception is raised |
OriginalResponse | The core response object if additional information is required - might be null if an exception is raised |
ContentLength | The length of the content which the server intends to send - could be -1 if the server doesn't send a content length header |
TotalContentRead | How much data has been read so far |
ContentReadThisRound | Content read since the last callback was raised |
PercentageComplete | Percentage completion of the download |
StatusCode | The http status code |
ReasonPhrase | The reason for the http status code |
IsSuccessStatusCode | Can the status code be considered a success code |
Exception | The exception raised if there was one, null otherwise |
HasContent | Did the server return any content |
HttpResponseMessage Methods
Method | Description |
---|---|
ReadAsString() | Returns the response as a string |
ReadAsString(encoding) | Returns the response as a string using the specified encoding |
ReadAsByteArray() | Returns the response as a byte array |
ReadAsStream() | Returns the response as a stream |
ReadAsJson() | Deserialises the json response and returns the resulting object |
UploadStatus (UploadStatusMessage)
Contains the progress of an upload, the UploadStatus callback does not need to be specified if you don't require upload progress. Will be raised perodically when UploadBlockSize bytes of data have been uploaded or when all data has been uploaded
UploadStatusMessage Properties
Property | Description |
---|---|
ContentLength | The length of the content to be uploaded |
TotalContentUploaded | How much data has been written so far |
ContentUploadedThisRound | Content uploaded since the last callback was raised |
PercentageComplete | Percentage completion of the upload |