diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index fc46865c5e..b8ddb2abfa 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -198,9 +198,11 @@ namespace URLHelpers data << getMangledParameters (url) << url.getPostData(); - // just a short text attachment, so use simple url encoding.. - headers << "Content-Type: application/x-www-form-urlencoded\r\nContent-length: " - << (int) data.getDataSize() << "\r\n"; + // if the user-supplied headers didn't contain a content-type, add one now.. + if (! headers.containsIgnoreCase ("Content-Type")) + headers << "Content-Type: application/x-www-form-urlencoded\r\n"; + + headers << "Content-length: " << (int) data.getDataSize() << "\r\n"; } } @@ -320,18 +322,18 @@ bool URL::isProbablyAnEmailAddress (const String& possibleEmailAddress) InputStream* URL::createInputStream (const bool usePostCommand, OpenStreamProgressCallback* const progressCallback, void* const progressCallbackContext, - const String& extraHeaders, + String headers, const int timeOutMs, StringPairArray* const responseHeaders) const { - String headers; MemoryBlock headersAndPostData; + if (! headers.endsWithChar ('\n')) + headers << "\r\n"; + if (usePostCommand) URLHelpers::createHeadersAndPostData (*this, headers, headersAndPostData); - headers += extraHeaders; - if (! headers.endsWithChar ('\n')) headers << "\r\n"; diff --git a/modules/juce_core/network/juce_URL.h b/modules/juce_core/network/juce_URL.h index 9381fa6ecb..82ae5880aa 100644 --- a/modules/juce_core/network/juce_URL.h +++ b/modules/juce_core/network/juce_URL.h @@ -251,7 +251,7 @@ public: InputStream* createInputStream (bool usePostCommand, OpenStreamProgressCallback* progressCallback = nullptr, void* progressCallbackContext = nullptr, - const String& extraHeaders = String::empty, + String extraHeaders = String::empty, int connectionTimeOutMs = 0, StringPairArray* responseHeaders = nullptr) const;