From a6c9fd26032b8976aaa4baf83765fedf36e10ed6 Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Thu, 4 Mar 2021 17:00:45 +0100 Subject: [PATCH 1/2] Fix WinHTTP GET parameter An additional ? was send to the server, resulting in ignoring the first get parameter --- src/msw/webrequest_winhttp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/webrequest_winhttp.cpp b/src/msw/webrequest_winhttp.cpp index fd576bd1de..11f8197118 100644 --- a/src/msw/webrequest_winhttp.cpp +++ b/src/msw/webrequest_winhttp.cpp @@ -330,7 +330,7 @@ void wxWebRequestWinHTTP::Start() wxString objectName(urlComps.lpszUrlPath, urlComps.dwUrlPathLength); if ( urlComps.dwExtraInfoLength ) - objectName += "?" + wxString(urlComps.lpszExtraInfo, urlComps.dwExtraInfoLength); + objectName += wxString(urlComps.lpszExtraInfo, urlComps.dwExtraInfoLength); // Open a request static const wchar_t* acceptedTypes[] = { L"*/*", NULL }; From 59a8f26b01030b6d2d745a78f2f584b50b303918 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 6 Mar 2021 12:11:59 +0100 Subject: [PATCH 2/2] Add a unit test for wxWebRequest query using URL parameters Check that passing URL parameters in the query string works as expected (this was broken with WinHTTP backend until the parent commit). --- tests/net/webrequest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/net/webrequest.cpp b/tests/net/webrequest.cpp index 4be896bbd4..dfb0465183 100644 --- a/tests/net/webrequest.cpp +++ b/tests/net/webrequest.cpp @@ -212,6 +212,21 @@ TEST_CASE_METHOD(RequestFixture, CHECK( request.GetResponse().AsString() == "The quick brown fox jumps over the lazy dog" ); } +TEST_CASE_METHOD(RequestFixture, + "WebRequest::Get::Param", "[net][webrequest][get]") +{ + if ( !InitBaseURL() ) + return; + + Create("/get?pi=3.14159265358979323"); + Run(); + + // We ought to really parse the returned JSON object, but to keep things as + // simple as possible for now we just treat it as a string. + CHECK_THAT( request.GetResponse().AsString().ToStdString(), + Catch::Contains("\"pi\": \"3.14159265358979323\"") ); +} + TEST_CASE_METHOD(RequestFixture, "WebRequest::Get::File", "[net][webrequest][get]") {