URL "broken" for parameterless POST req

JUCE 1.14

Heads up If you trying for example to call a webservice method that takes no input parameters through HTTP POST, URL::readEntireXmlStream (true) is “broken” (as are the other stream funcions in POST mode). The code that breaks is in juce_openInternetFile():

116   HINTERNET request = HttpOpenRequest (connection,
117                                            (postText.isEmpty()) ? _T("GET")
118                                            : _T("POST"),
119                                            uc.lpszUrlPath,
120                                            0, 0,
121                                            mimeTypes,
122                                            INTERNET_FLAG_RELOAD |
123                                            INTERNET_FLAG_NO_CACHE_WRITE, 0);

…which kindly turns your empty POST into a GET :smiley:

Workaround is to call even parameterless methods with a dummy parameter:

URL theUrl(T("http://myhost.com/webservice.asmx/MyFunction?dummy="));

or

InputStream *s =theUrl.createPostInputStream(T("dummy"));

Of course then you have to muck about to get the XmlDocument.
This works ok with my webservices, but your mileage may vary.

cheers, Colin

yeah - you’re right, that’s a silly way of deciding whether it’s a put or get… I’ll fix it up so it does a better job of it.