URL class, POST broken in latest develop

Develop tip, there’s either a bug or a breaking change for URLs with POST data.

We have been creating our URLs like this for years:

URL theURL = URL (url).withParameter ("paramName", "paramValue");
std::unique_ptr<InputStream> input (theURL.createInputStream (true));

Now no data is passing through neither as POST nor as GET.

Does the URL object contain any POST data added with the withPOSTData() methods or are you just trying to send the parameters in the request body as a POST request?

Never used withPOSTData, I’ll have a look, but as I wrote, we have always just used withParameter and never had issues until the latest commits.
The description of withParameter is

Returns a copy of this URL, with a GET or POST parameter added to the end.

Passing true to createInputStream should be more than enough.

doPostLikeRequest if true, the parameters added to this class will be transferred via the HTTP headers which is typical for POST requests. Otherwise the parameters will be added to the URL address. Additionally, if the parameter httpRequestCmd is not specified (or empty) then this parameter will determine which HTTP request command will be used (POST or GET).

Ok, using withPOSTData works. Still, I think this is a breaking change/bug that should be addressed.

Yeah we’ll take a look, was just useful to narrow it down as I think I know what’s going on now. Thanks

1 Like

doPostLikeRequest will urlencode the parameters in the post data, prior to the post data (if defined, potentially breaking it). By RFC, doing that will also require to have a content type of application/x-www-form-urlencoded in order to tell the receiver that the post data will contain urlencoded parameters (which, if also contains some other non urlencoded, non key value string after it, the body will be invalid)

This should now be fixed on develop:

1 Like

Thank you!