From aecbf88998ff657fe19f45ba85a6526de5d317e0 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 16 Dec 2014 16:04:21 +0000 Subject: [PATCH] Added method URL::withParameters --- modules/juce_core/network/juce_URL.cpp | 11 +++++++++++ modules/juce_core/network/juce_URL.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 10358023c8..a4cc02e726 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -397,6 +397,17 @@ URL URL::withParameter (const String& parameterName, return u; } +URL URL::withParameters (const StringPairArray& parametersToAdd) const +{ + URL u (*this); + + for (int i = 0; i < parametersToAdd.size(); ++i) + u.addParameter (parametersToAdd.getAllKeys()[i], + parametersToAdd.getAllValues()[i]); + + return u; +} + URL URL::withPOSTData (const String& newPostData) const { URL u (*this); diff --git a/modules/juce_core/network/juce_URL.h b/modules/juce_core/network/juce_URL.h index 06d8fb732d..697ce0c5de 100644 --- a/modules/juce_core/network/juce_URL.h +++ b/modules/juce_core/network/juce_URL.h @@ -140,6 +140,12 @@ public: URL withParameter (const String& parameterName, const String& parameterValue) const; + /** Returns a copy of this URL, with a set of GET or POST parameters added. + This is a convenience method, equivalent to calling withParameter for each value. + @see withParameter + */ + URL withParameters (const StringPairArray& parametersToAdd) const; + /** Returns a copy of this URL, with a file-upload type parameter added to it. When performing a POST where one of your parameters is a binary file, this