URL withPostData downloadAsFile() on iOS

Hi there,
I am trying to fetch data with a post data request from the iPad simulator. This works perfectly on macOS (and windows), but from iOS the data on the server is empty.
The server is using https with letsencrypt.

It sounds it could be an entitlement or permissions issue, but could be anything else.
What do I have to do, if it is a user error, or which entitlement could work here?

Thanks!

So I was debugging into juce_network_mac.mm. The request is assembled in the constructor of
BackgroundDownloadTask
But there is no mention of url.postData.

I might be wrong, but is it possible that it is not implemented?

The link in the comment to a github repo is no longer valid or private.
That sounds related to postData.

What can be done so I can send postData from an iOS device?

Thanks

So with some more digging I found the missing command:

        if (options.usePost)
            [request setHTTPMethod: @"POST"];

+++     if (urlToUse.getPostData().isNotEmpty())
+++         [request setHTTPBody:[juceStringToNS(urlToUse.getPostData()) dataUsingEncoding:NSUTF8StringEncoding]];

        StringArray headerLines;
        headerLines.addLines (options.extraHeaders);
        headerLines.removeEmptyStrings (true);

Would be great if you could add that.

1 Like

@daniel thanks for reporting this should be resolved on the latest tip of develop.

1 Like

Great, that works perfectly.
Thank you @anthony-nicholls for the quick merge, and kudos for improving the fix.
There’s no need to convert to a string :slight_smile:

1 Like