Commit Graph

21 Commits

Author SHA1 Message Date
Vadim Zeitlin
20a3317839 Rename wxWebRequestEvent::GetResponseFileName() to GetDataFile()
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.
2021-01-12 03:34:40 +01:00
Vadim Zeitlin
252373e540 Allow a simple way to rest requesting the given URL in the test
This does nothing more than just running a GET request for the given
URL for testing purposes.
2021-01-11 02:30:43 +01:00
Vadim Zeitlin
0588b0e7ce Extract all the wxWebRequest test sections in separate tests
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.
2021-01-10 21:27:51 +01:00
Vadim Zeitlin
31a441e814 Use separate test cases for wxWebRequest auth tests
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.
2021-01-10 21:27:15 +01:00
Vadim Zeitlin
1e6d6be8bb Add wxWebCredentials and use it in SetCredentials()
Prefer using a class encapsulating both the user name and the password
to using a pair of variables.
2021-01-10 21:27:15 +01:00
Vadim Zeitlin
8820bb9609 Test using wrong credentials in the auth unit tests too
In addition to verifying that the correct password works, check that
using a wrong one does not.
2021-01-10 00:41:05 +01:00
Vadim Zeitlin
b64ad7f06d Test Basic, not Digest, authentication method in the test
Basic authentication method unit test somehow used Digest authentication
method.
2021-01-10 00:33:39 +01:00
Vadim Zeitlin
989cafe535 Take raw pointer and not wxSharedPtr<> in SetData()
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.
2021-01-04 01:57:36 +01:00
Vadim Zeitlin
63f1260739 Skip wxWebRequest authentication tests when using NSURLSession
The NSURLSession-based backend is missing authentication support, so
these tests always fail there, skip them for now.
2020-12-30 14:41:17 +01:00
Vadim Zeitlin
50424cba2c Change wxWebRequest and related objects to hide ref counting
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.
2020-12-30 02:02:20 +01:00
Vadim Zeitlin
8b632bb892 Enable wxWebRequest tests by default
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.
2020-12-26 16:43:03 +01:00
Vadim Zeitlin
6a064c85d4 Compile even less code when wxUSE_WEBREQUEST==0 in the test
Move the check slightly higher, there is no need to include the headers
if we're not going to compile any tests anyhow.
2020-12-26 16:00:03 +01:00
Vadim Zeitlin
b37c7417f6 Don't make wxWebRequest::SplitParameters() public
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.
2020-12-13 02:41:01 +01:00
Vadim Zeitlin
64a3801160 Tweaks to wxWebRequest::SetData() overload taking stream
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.
2020-12-12 18:46:28 +01:00
Vadim Zeitlin
fcaccbf12c Avoid -Wswitch warnings in wxWebRequest test
No real changes, just suppress the warnings about not handling all
states in a switch.
2020-12-12 18:12:44 +01:00
Tobias Taschner
f40e2e64d9 Add wxWebRequest::SplitParameters method
This method is adapted for use in wxWidgets from the Poco library.
2018-12-10 19:37:55 +01:00
Tobias Taschner
c24efa9821 Implement additional storage targets 2018-12-10 19:37:42 +01:00
Tobias Taschner
d4362f4bca Add wxWebResponse::AsString() test 2018-12-10 19:37:41 +01:00
Tobias Taschner
cf85c04d25 Add wxWebRequest progress methods 2018-12-10 19:37:38 +01:00
Tobias Taschner
4fd6091513 Implement WinHTTP authentication 2018-12-10 19:37:35 +01:00
Tobias Taschner
6db3f5f115 Add unit test for wxWebRequest
The environment variable WX_TEST_WEBREQUEST_URL has to
be set to https://httpbin.org or a local instance of it
to be run.
2018-12-10 19:37:31 +01:00