60 bool operator== (
const URL&)
const;
61 bool operator!= (
const URL&)
const;
72 String toString (
bool includeGetParameters)
const;
75 bool isEmpty()
const noexcept;
78 bool isWellFormed()
const;
96 String getSubPath (
bool includeGetParameters =
false)
const;
101 String getQueryString()
const;
106 String getAnchorString()
const;
116 bool isLocalFile()
const;
127 File getLocalFile()
const;
137 String getFileName()
const;
152 [[nodiscard]]
URL withNewDomainAndPath (
const String& newFullPath)
const;
161 [[nodiscard]]
URL withNewSubPath (
const String& newPath)
const;
167 URL getParentURL()
const;
181 URL getChildURL (
const String& subPath)
const;
194 [[nodiscard]]
URL withParameter (
const String& parameterName,
195 const String& parameterValue)
const;
207 [[nodiscard]]
URL withAnchor (
const String& anchor)
const;
220 [[nodiscard]]
URL withFileToUpload (
const String& parameterName,
221 const File& fileToUpload,
222 const String& mimeType)
const;
234 [[nodiscard]]
URL withDataToUpload (
const String& parameterName,
237 const String& mimeType)
const;
273 [[nodiscard]]
URL withPOSTData (
const String& postData)
const;
283 [[nodiscard]]
URL withPOSTData (
const MemoryBlock& postData)
const;
296 bool launchInDefaultBrowser()
const;
302 static bool isProbablyAWebsiteURL (
const String& possibleURL);
307 static bool isProbablyAnEmailAddress (
const String& possibleEmailAddress);
310 enum class ParameterHandling
359 [[nodiscard]]
InputStreamOptions withConnectionTimeoutMs (
int connectionTimeoutMs)
const;
375 [[nodiscard]]
InputStreamOptions withNumRedirectsToFollow (
int numRedirectsToFollow)
const;
387 ParameterHandling getParameterHandling()
const noexcept {
return parameterHandling; }
388 std::function<
bool (
int,
int)> getProgressCallback()
const noexcept {
return progressCallback; }
389 String getExtraHeaders()
const noexcept {
return extraHeaders; }
390 int getConnectionTimeoutMs()
const noexcept {
return connectionTimeOutMs; }
391 StringPairArray* getResponseHeaders()
const noexcept {
return responseHeaders; }
392 int* getStatusCode()
const noexcept {
return statusCode; }
393 int getNumRedirectsToFollow()
const noexcept {
return numRedirectsToFollow; }
394 String getHttpRequestCmd()
const noexcept {
return httpRequestCmd; }
398 const ParameterHandling parameterHandling;
402 int connectionTimeOutMs = 0;
404 int* statusCode =
nullptr;
405 int numRedirectsToFollow = 5;
465 bool usePost =
false;
468 [[nodiscard]]
auto withExtraHeaders (
String value)
const {
return with (&DownloadTaskOptions::extraHeaders, std::move (value)); }
483 [[nodiscard]]
auto withUsePost (
bool value)
const {
return with (&DownloadTaskOptions::usePost, value); }
486 template <
typename Member,
typename Value>
490 copy.*member = std::forward<Value> (value);
536 int64 contentLength = -1, downloaded = 0;
537 bool finished =
false, error =
false;
550 static void juce_iosURLSessionNotify (
const String&);
558 [[deprecated (
"Use the overload with a DownloadTaskOptions argument instead")]]
561 DownloadTaskListener* listener =
nullptr,
562 bool usePostCommand =
false);
574 const DownloadTaskOptions& options);
591 bool readEntireBinaryStream (
MemoryBlock& destData,
592 bool usePostCommand =
false)
const;
609 String readEntireTextStream (
bool usePostCommand =
false)
const;
645 static String addEscapeChars (
const String& stringToAddEscapeCharsTo,
647 bool roundBracketsAreLegal =
true);
658 static String removeEscapeChars (
const String& stringToRemoveEscapeCharsFrom);
665 static URL createWithoutParsing (
const String& url);
669 using OpenStreamProgressCallback =
bool (
void* context,
int bytesSent,
int totalBytes);
675 [[deprecated (
"New code should use the method which takes an InputStreamOptions argument instead.")]]
677 OpenStreamProgressCallback* progressCallback =
nullptr,
678 void* progressCallbackContext =
nullptr,
680 int connectionTimeOutMs = 0,
681 StringPairArray* responseHeaders =
nullptr,
682 int* statusCode =
nullptr,
683 int numRedirectsToFollow = 5,
684 String httpRequestCmd = {})
const;
690 struct Bookmark :
public ReferenceCountedObject
692 using Ptr = ReferenceCountedObjectPtr<Bookmark>;
700 Bookmark::Ptr bookmark;
702 friend void setURLBookmark (URL&,
void*);
703 friend void* getURLBookmark (URL&);
707 struct Upload :
public ReferenceCountedObject
709 Upload (
const String&,
const String&,
const String&,
const File&, MemoryBlock*);
710 String parameterName, filename, mimeType;
718 friend class WebInputStream;
720 URL (
const String&,
int);
722 void addParameter (
const String&,
const String&);
723 bool hasBodyDataToSend()
const;
724 void createHeadersAndPostData (String&, MemoryBlock&,
bool)
const;
725 URL withUpload (Upload*)
const;
727 static ParameterHandling toHandling (
bool);
728 static File fileFromFileSchemeURL (
const URL&);
729 String getDomainInternal (
bool)
const;
733 MemoryBlock postData;
734 StringArray parameterNames, parameterValues;
737 ReferenceCountedArray<Upload> filesToUpload;
Represents a local file or directory.
A class to hold a resizable block of raw data.
A special array for holding a list of strings.
A container for holding a set of strings which are keyed by another string.
Holds options that can be specified when starting a new download with downloadToFile().
auto withSharedContainer(String value) const
On iOS, specifies the container where the downloaded file will be stored.
auto withExtraHeaders(String value) const
Specifies headers to add to the request.
auto withListener(DownloadTaskListener *value) const
Specifies an observer for the download task.
auto withUsePost(bool value) const
Specifies whether a post command should be used.
Represents a download task.
bool hadError() const
Returns true if there was an error.
int64 getLengthDownloaded() const
Returns the number of bytes that have been downloaded so far.
bool isFinished() const
Returns true if the download finished or there was an error.
File getTargetLocation() const
Returns the target file location that was provided in URL::downloadToFile.
int statusCode() const
Returns the status code of the server's response.
int64 getTotalLength() const
Returns the total length of the download task.
Represents a URL and has a bunch of useful functions to manipulate it.
const MemoryBlock & getPostDataAsMemoryBlock() const noexcept
Returns the data that was set using withPOSTData() as a MemoryBlock.
String getPostData() const
Returns the data that was set using withPOSTData().
const StringArray & getParameterValues() const noexcept
Returns an array of the values of all the URL's parameters.
const StringArray & getParameterNames() const noexcept
Returns an array of the names of all the URL's parameters.
Represents a shared variant value.
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
long long int64
A platform-independent 64-bit integer type.
Used to receive callbacks for download progress.
virtual void finished(DownloadTask *task, bool success)=0
Called when the download has finished.