West Wind Internet Protocols 4.68 |
wwHTTP::cResultCode
|
A valid response from a server is "200".
Note that this property might be important in some situations as wwHTTP will treat a server 500 error as a valid response. Most HTTP servers return a descriptive HTML response to a 500 (or 404) error and this response is faithfully returned by wwHTTP. So if you need to discard output from a failed request you might want to add checking for the cResultCode property.
oHTTP = CREATEOBJECT("wwHTTP") lcFileName = "d:\temp\wwipstuff.zip" *** Note: Invalid filename results in 404 error oHTTP.HTTPGet("http://www.west-wind.com/files/wwipstusff.zip",,,lcFileName) *** Check for HTTP protocol errors first IF oHTTP.nError # 0 ? oHTTP.nError ? oHTTP.cErrorMSg RETURN ENDIF *** Then check the result code IF oHTTP.cResultCode # "200" ? oHTTP.cResultCode ? FILETOSTR(lcFileName) && Echo message from server RETURN ENDIF *** Display downloaded file IF FILE(lcFileName) GoUrl(lcFileName) ENDIF
Only the final header is returned so if you have a redirect the redirect result value is returned not the 302 moved header but the 200 of the final document.
| Values: |
string Typical values |