(C#) Example: Http.DownloadSb method
Demonstrates the DownloadSb method.
bool success = false;
Chilkat.Http http = new Chilkat.Http();
http.KeepResponseBody = true;
Chilkat.StringBuilder sb = new Chilkat.StringBuilder();
success = http.DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt","utf-8",sb);
int statusCode = http.LastStatus;
if (success == false) {
if (statusCode == 0) {
// Unable to either send the request or get the response.
Debug.WriteLine(http.LastErrorText);
}
else {
// We got a response, but the status code was not in the 200s
Debug.WriteLine("Response status code: " + Convert.ToString(statusCode));
// Examine the response body.
Debug.WriteLine("Response body:");
Debug.WriteLine(http.LastResponseBody);
}
Debug.WriteLine("Download failed.");
}
else {
Debug.WriteLine("Download success, response status = " + Convert.ToString(statusCode));
Debug.WriteLine(sb.GetAsString());
}
|