This is similar to b03eaceea6 (Disable WebRequest::SSL::Ignore unit test
under AppVeyor, 2021-08-04) and just warns about the wxWebRequest
cancelling test failure when running it under AppVeyor instead of
failing the entire test suite, as this does happen sporadically (but
regularly) there for as yet unknown reason.
This test sporadically fails in builds with different compilers (both
MSVC and gcc) there for unknown reasons. Until we can find, and fix, the
underlying problem, disable this test to avoid spurious CI failures.
We already did it just before processing the state change event, but
this was too late, as the object could have been already deleted by then
and this actually happened with the example from wxWebRequest
documentation.
Do it earlier now, as soon as the request becomes active, which normally
happens when Start() is called, and keep the reference until the event
is processed after the request reaches one of the final states
(completed, failed or cancelled).
Add a unit test checking that deleting the wxWebRequest object doesn't
prevent the request from running to the completion any more.
The simple test added in 59a8f26b01 (Add a unit test for wxWebRequest
query using URL parameters, 2021-03-06) worked when using httpbin.org,
but not when running httpbin locally, as it doesn't pretty-print JSON by
default.
Skip optional whitespace to make it work in both cases.
Although httpbin doesn't return any body for the other 4xx statuses, it
does make an exception for this one, so we can use it for testing
instead of the even less reliable httpstat.us which regularly returns
503 server error instead of the expected 418.
This probably also makes the workaround for Ubuntu 14.04 unnecessary, so
remove it.
It's up to the application code to decide how it handles the HTTP status
codes it gets back from server, there is no need to have a special
method for handling them in wxWebRequest itself.
We also shouldn't skip downloading the response body just because it was
unsuccessful, we may still need it (e.g. it's very common to return the
detailed error description in a JSON object in the message body when
returning some 4xx error), so don't do it in wxMSW implementation and
add a test verifying that we still get the expected body even for an
error status.
Also improve wxWebRequest::State values documentation.
Don't give it any tags other than "." as we don't want to execute it
when these tags are specified, only when it's explicitly selected by
using its name on the command line.
This is shorter and doesn't imply that just the name (and not the full
path) is being returned.
Also rename wxWebResponse::GetFileName() to GetDataFile() for the same
reasons and for consistency. And document this previously undocumented
method.
As in 31a441e814 (Use separate test cases for wxWebRequest auth tests,
2021-01-10), there is no real reason to use sections here as we don't
reuse anything between them and using separate tests makes it easier to
run individual tests and, especially, combinations of them.
This commit is best viewed ignoring whitespace-only changes.
This allows to easily run both auth tests at once without all the other
tests and it's not like we reuse much (or actually anything) by having
them as sections in the same test case anyhow.
This commit is best viewed ignoring whitespace-only changes.
Using shared pointer seems to be ill-advised here, the stream shouldn't
be shared as it's going to be used by wxWebRequest itself and can't be
used by the application code in parallel, so the ownership transfer
semantics is more appropriate.
We could take a wxScopedPtr<> instead, but wx API takes ownership of raw
pointers everywhere else, so do it here too.
Incidentally fix a bug with calling IsOk() on a possibly null pointer.
Don't force the application code to deal with wxObjectDataPtr<> or,
worse, calling {Inc,Dec}Ref() manually by hiding it inside the wx
objects themselves and giving the value-like semantics to them.
There should be no real changes in the behaviour, but the API does
change significantly. Notably, wxWebRequest is not a wxEvtHandler itself
any longer, as this would be incompatible with the value semantics, and
an event handler needs to be specified when creating it, so that it
could be notified about the request state changes.
Don't require WX_TEST_WEBREQUEST_URL environment variable to be set, but
only allow defining it to override the default https://httpbin.org value
or to disable the tests by setting it to 0.
They're not necessary to use this class and we may consider exporting
them later, possibly with a better API and more tests, if really needed.
Also do change their API slightly by leaving only a single function and
returning the value instead of using an out parameter for it to make it
simpler to use.
Check that the stream is valid, if specified at all, and return false if
it isn't -- or if no size was specified and determining stream size
failed.
Check for SetData() success in the test to provide better diagnostics in
case the file it uses is not found (as is the case when running the test
from another directory, for example).
Also pass wxSharedPtr<> by const reference instead of by value to avoid
unnecessary copies.