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.
This commit is contained in:
Vadim Zeitlin
2020-12-12 18:46:28 +01:00
parent 92e41a7477
commit 64a3801160
4 changed files with 21 additions and 6 deletions

View File

@@ -172,8 +172,10 @@ TEST_CASE_METHOD(RequestFixture, "WebRequest", "[net][.]")
SECTION("PUT file data")
{
Create("/put");
request->SetData(wxSharedPtr<wxInputStream>(new wxFileInputStream("horse.png")),
"image/png");
wxSharedPtr<wxInputStream> is(new wxFileInputStream("horse.png"));
REQUIRE( is->IsOk() );
request->SetData(is, "image/png");
request->SetMethod("PUT");
Run();
}