wwHTTP::cResultCode

Returns the HTTP result code from a request. These are HTTP spec result codes that are typically returned in the HTTP response header from the Web Server.

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.

o.cResultCode

Default Value

string

Typical values
200 - OK
500 - Server Error
404 - File not found
400 errors - Access errors
300 range - Redirects

See also:

Class wwHTTP


  Last Updated: 4/5/2005 | © West Wind Technologies, 2008