diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index ac1b02de45..eae06cfa09 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -7136,6 +7136,7 @@ URL::URL (const String& url_) URL::URL (const URL& other) : url (other.url), + postData (other.postData), parameters (other.parameters), filesToUpload (other.filesToUpload), mimeTypes (other.mimeTypes) @@ -7145,6 +7146,7 @@ URL::URL (const URL& other) const URL& URL::operator= (const URL& other) { url = other.url; + postData = other.postData; parameters = other.parameters; filesToUpload = other.filesToUpload; mimeTypes = other.mimeTypes; @@ -7402,14 +7404,13 @@ private: } else { - // just a short text attachment, so use simple url encoding.. - const String params (getMangledParameters (url.getParameters())); + appendUTF8ToPostData (getMangledParameters (url.getParameters())); + appendUTF8ToPostData (url.getPostData()); + // just a short text attachment, so use simple url encoding.. headers = "Content-Type: application/x-www-form-urlencoded\r\nContent-length: " - + String ((int) strlen (params.toUTF8())) + + String (postData.getSize()) + "\r\n"; - - appendUTF8ToPostData (params); } } @@ -7497,6 +7498,13 @@ const URL URL::withFileToUpload (const String& parameterName, return u; } +const URL URL::withPOSTData (const String& postData_) const +{ + URL u (*this); + u.postData = postData_; + return u; +} + const StringPairArray& URL::getParameters() const throw() { return parameters; @@ -31849,7 +31857,7 @@ VstIntPtr VSTPluginInstance::handleCallback (VstInt32 opcode, VstInt32 index, Vs return 1; case audioMasterGetSampleRate: - return (VstIntPtr) getSampleRate(); + return (VstIntPtr) (getSampleRate() > 0 ? getSampleRate() : 44100); case audioMasterGetBlockSize: return (VstIntPtr) getBlockSize(); @@ -31926,6 +31934,9 @@ const String VSTPluginInstance::getVersion() const throw() String s; + if (v == 0 || v == -1) + v = getVersionNumber(); + if (v != 0) { int versionBits[4]; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 59c6a2d8bf..329d8000e9 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -12313,6 +12313,24 @@ public: */ const StringPairArray& getMimeTypesOfUploadFiles() const throw(); + /** Returns a copy of this URL, with a block of data to send as the POST data. + + If you're setting the POST data, be careful not to have any parameters set + as well, otherwise it'll all get thrown in together, and might not have the + desired effect. + + If the URL already contains some POST data, this will replace it, rather + than being appended to it. + + This data will only be used if you specify a post operation when you call + createInputStream(). + */ + const URL withPOSTData (const String& postData) const; + + /** Returns the data that was set using withPOSTData(). + */ + const String getPostData() const throw() { return postData; } + /** Tries to launch the system's default browser to open the URL. Returns true if this seems to have worked. @@ -12432,7 +12450,7 @@ public: juce_UseDebuggingNewOperator private: - String url; + String url, postData; StringPairArray parameters, filesToUpload, mimeTypes; }; diff --git a/src/juce_appframework/audio/plugins/formats/juce_VSTPluginFormat.cpp b/src/juce_appframework/audio/plugins/formats/juce_VSTPluginFormat.cpp index 5d526996f5..e5a8ea14fb 100644 --- a/src/juce_appframework/audio/plugins/formats/juce_VSTPluginFormat.cpp +++ b/src/juce_appframework/audio/plugins/formats/juce_VSTPluginFormat.cpp @@ -2437,7 +2437,7 @@ VstIntPtr VSTPluginInstance::handleCallback (VstInt32 opcode, VstInt32 index, Vs return 1; case audioMasterGetSampleRate: - return (VstIntPtr) getSampleRate(); + return (VstIntPtr) (getSampleRate() > 0 ? getSampleRate() : 44100); case audioMasterGetBlockSize: return (VstIntPtr) getBlockSize(); @@ -2515,6 +2515,9 @@ const String VSTPluginInstance::getVersion() const throw() String s; + if (v == 0 || v == -1) + v = getVersionNumber(); + if (v != 0) { int versionBits[4]; diff --git a/src/juce_core/io/network/juce_URL.cpp b/src/juce_core/io/network/juce_URL.cpp index f3fa37251f..4ae15ab8e8 100644 --- a/src/juce_core/io/network/juce_URL.cpp +++ b/src/juce_core/io/network/juce_URL.cpp @@ -80,6 +80,7 @@ URL::URL (const String& url_) URL::URL (const URL& other) : url (other.url), + postData (other.postData), parameters (other.parameters), filesToUpload (other.filesToUpload), mimeTypes (other.mimeTypes) @@ -89,6 +90,7 @@ URL::URL (const URL& other) const URL& URL::operator= (const URL& other) { url = other.url; + postData = other.postData; parameters = other.parameters; filesToUpload = other.filesToUpload; mimeTypes = other.mimeTypes; @@ -352,14 +354,13 @@ private: } else { - // just a short text attachment, so use simple url encoding.. - const String params (getMangledParameters (url.getParameters())); + appendUTF8ToPostData (getMangledParameters (url.getParameters())); + appendUTF8ToPostData (url.getPostData()); + // just a short text attachment, so use simple url encoding.. headers = "Content-Type: application/x-www-form-urlencoded\r\nContent-length: " - + String ((int) strlen (params.toUTF8())) + + String (postData.getSize()) + "\r\n"; - - appendUTF8ToPostData (params); } } @@ -449,6 +450,13 @@ const URL URL::withFileToUpload (const String& parameterName, return u; } +const URL URL::withPOSTData (const String& postData_) const +{ + URL u (*this); + u.postData = postData_; + return u; +} + const StringPairArray& URL::getParameters() const throw() { return parameters; diff --git a/src/juce_core/io/network/juce_URL.h b/src/juce_core/io/network/juce_URL.h index 6505b1ec08..63ab0c1ec2 100644 --- a/src/juce_core/io/network/juce_URL.h +++ b/src/juce_core/io/network/juce_URL.h @@ -121,6 +121,24 @@ public: */ const StringPairArray& getMimeTypesOfUploadFiles() const throw(); + /** Returns a copy of this URL, with a block of data to send as the POST data. + + If you're setting the POST data, be careful not to have any parameters set + as well, otherwise it'll all get thrown in together, and might not have the + desired effect. + + If the URL already contains some POST data, this will replace it, rather + than being appended to it. + + This data will only be used if you specify a post operation when you call + createInputStream(). + */ + const URL withPOSTData (const String& postData) const; + + /** Returns the data that was set using withPOSTData(). + */ + const String getPostData() const throw() { return postData; } + //============================================================================== /** Tries to launch the system's default browser to open the URL. @@ -248,7 +266,7 @@ public: juce_UseDebuggingNewOperator private: - String url; + String url, postData; StringPairArray parameters, filesToUpload, mimeTypes; };