If I’m offline and do the following :
WebInputStream wis ({ "https://juce.com/" }, false);
int status = wis.getStatusCode();
I got the status code 0, which is not an official status code.
should it be initialized to 404 rather than 0?
If I’m offline and do the following :
WebInputStream wis ({ "https://juce.com/" }, false);
int status = wis.getStatusCode();
I got the status code 0, which is not an official status code.
should it be initialized to 404 rather than 0?
But a 404 would imply it is a response from the server.
IMHO you should use WebInputStream::isError() before evaluating the status code, especially as the docs state “Returns the status code returned by the http server.”
ah yes, that makes sense!
(worth mentioning that WebInputStream::isError()
does not call connect()
if there is no established connection already (unlike WebInputStream.getStatusCode()
)
Ah right, forgot about the “convenience connect” in getStatusCode().
So yes, you will have to call connect manually before you can check isError(). Thanks for pointing that out.