From 2a983067ab8d7ee44c5e6228eac47340ec7e9abb Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 11 Jan 2017 15:45:56 +0000 Subject: [PATCH] Fixed bug in OSX network code where Content-Type headers were not being added to HTTP POST requests unless specified manually and renamed a variable in URL::createHeadersAndPostData() method --- modules/juce_core/native/juce_mac_Network.mm | 18 +++++++++--------- modules/juce_core/network/juce_URL.cpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) 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) {