(PureBasic) Setting a HTTP Max Response Size
Demonstrates the MaxResponseSize property.
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
success.i = 0
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
maxSz.i = 16384
CkHttp::setCkMaxResponseSize(http, maxSz)
; Try to get something larger, such as hamlet.xml which is 279658 bytes
xmlStr.s = CkHttp::ckQuickGetStr(http,"https://chilkatsoft.com/hamlet.xml")
If CkHttp::ckLastMethodSuccess(http) = 0
; If the LastErrorText contains the string "MaxResponseSize",
; then the HTTP request failed because the response body would've been larger than the max allowed response size.
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
ProcedureReturn
EndIf
Debug "OK"
CkHttp::ckDispose(http)
ProcedureReturn
EndProcedure
|