Can URL parameter encoding be independent of the inclusion of postData?

So JUCE URL currently allows an input stream to be created with a boolean setting for whether to use a POST or a GET. If you use a GET, the parameters get included in the query string (?x=2 etc.) and if you use a POST, they get included in the body along with the post data.

I need to send a PUT request, wherein I have post data to send, but the parameters need to be in the query string like a GET. Is there any way to do this as-is? postData set in the URL isn’t included if I set the boolean to GET mode, even if I change the request command to something other than GET.

If not doable now, could this be patched in if we develop it here and submit code for it?

The last parameter of URL::createInputStream allows you to specify which http command to use. You can also then specify if the command should be executed with post data or not (by setting doPostLikeRequest to true). You can also just add extra get parameters by just pretending they are part of the URL subpath.

Would it work if doPostLikeRequest became usePostStyleParameters and if data was appended in get style requests? That way this use case is supported as far as I understand.

Your use case is currently already supported. When doPostLikeRequest is true it will simply send any postData as post data in your request - you can still specify which http command you want to use and you can still add extra get parameters to the URL.

I am trying to do this same thing (uploading to Azure sas storage), but I can’t find the right combination of parameters to get it to work. If I set doPostLikeRequest to true, the URL class strips my parameters from the url and inserts them into the beginning of the body.

They get stripped the juce_win32_Network.cpp version of bool WebInputStream::Pimpl::connect (WebInputStream::Listener* listener)

Well, look at that, URL::createWithoutParsing(urlAddress) seems to solve the whole problem!

1 Like