diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index 86fd8fc955..77fb5d18d1 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -1018,6 +1018,15 @@ private: { [req setHTTPMethod: [NSString stringWithUTF8String: httpRequestCmd.toRawUTF8()]]; + if (isPost) + { + WebInputStream::createHeadersAndPostData (url, headers, postData); + + if (postData.getSize() > 0) + [req setHTTPBody: [NSData dataWithBytes: postData.getData() + length: postData.getSize()]]; + } + StringArray headerLines; headerLines.addLines (headers); headerLines.removeEmptyStrings (true); @@ -1031,15 +1040,6 @@ private: [req addValue: juceStringToNS (value) forHTTPHeaderField: juceStringToNS (key)]; } - if (isPost) - { - WebInputStream::createHeadersAndPostData (url, headers, postData); - - if (postData.getSize() > 0) - [req setHTTPBody: [NSData dataWithBytes: postData.getData() - length: postData.getSize()]]; - } - connection = new URLConnectionState (req, numRedirectsToFollow); } } diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 67c5180948..96e052e862 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -354,9 +354,9 @@ URL URL::getChildURL (const String& subPath) const return u; } -void URL::createHeadersAndPostData (String& headers, MemoryBlock& headersAndPostData) const +void URL::createHeadersAndPostData (String& headers, MemoryBlock& postDataToWrite) const { - MemoryOutputStream data (headersAndPostData, false); + MemoryOutputStream data (postDataToWrite, false); if (filesToUpload.size() > 0) {