(Chilkat2-Python) Example: Http.DownloadSb method
Demonstrates the DownloadSb method.
import chilkat2
success = False
http = chilkat2.Http()
http.KeepResponseBody = True
sb = chilkat2.StringBuilder()
success = http.DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt","utf-8",sb)
statusCode = http.LastStatus
if (success == False):
if (statusCode == 0):
# Unable to either send the request or get the response.
print(http.LastErrorText)
else:
# We got a response, but the status code was not in the 200s
print("Response status code: " + str(statusCode))
# Examine the response body.
print("Response body:")
print(http.LastResponseBody)
print("Download failed.")
else:
print("Download success, response status = " + str(statusCode))
print(sb.GetAsString())
|