LMMS
Loading...
Searching...
No Matches
juce_URL.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
28
29URL::URL (const String& u) : url (u)
30{
31 init();
32}
33
34URL::URL (File localFile)
35{
36 if (localFile == File())
37 return;
38
39 #if JUCE_WINDOWS
40 bool isUncPath = localFile.getFullPathName().startsWith ("\\\\");
41 #endif
42
43 while (! localFile.isRoot())
44 {
45 url = "/" + addEscapeChars (localFile.getFileName(), false) + url;
46 localFile = localFile.getParentDirectory();
47 }
48
49 url = addEscapeChars (localFile.getFileName(), false) + url;
50
51 #if JUCE_WINDOWS
52 if (isUncPath)
53 {
54 url = url.fromFirstOccurrenceOf ("/", false, false);
55 }
56 else
57 #endif
58 {
59 if (! url.startsWithChar (L'/'))
60 url = "/" + url;
61 }
62
63 url = "file://" + url;
64
66}
67
69{
70 auto i = url.indexOfChar ('?');
71
72 if (i >= 0)
73 {
74 do
75 {
76 auto nextAmp = url.indexOfChar (i + 1, '&');
77 auto equalsPos = url.indexOfChar (i + 1, '=');
78
79 if (nextAmp < 0)
80 {
81 addParameter (removeEscapeChars (equalsPos < 0 ? url.substring (i + 1) : url.substring (i + 1, equalsPos)),
82 equalsPos < 0 ? String() : removeEscapeChars (url.substring (equalsPos + 1)));
83 }
84 else if (nextAmp > 0 && equalsPos < nextAmp)
85 {
86 addParameter (removeEscapeChars (equalsPos < 0 ? url.substring (i + 1, nextAmp) : url.substring (i + 1, equalsPos)),
87 equalsPos < 0 ? String() : removeEscapeChars (url.substring (equalsPos + 1, nextAmp)));
88 }
89
90 i = nextAmp;
91 }
92 while (i >= 0);
93
94 url = url.upToFirstOccurrenceOf ("?", false, false);
95 }
96}
97
98URL::URL (const String& u, int) : url (u) {}
99
101{
102 return URL (u, 0);
103}
104
105bool URL::operator== (const URL& other) const
106{
107 return url == other.url
108 && postData == other.postData
111 && filesToUpload == other.filesToUpload;
112}
113
114bool URL::operator!= (const URL& other) const
115{
116 return ! operator== (other);
117}
118
119namespace URLHelpers
120{
121 static String getMangledParameters (const URL& url)
122 {
124 String p;
125
126 for (int i = 0; i < url.getParameterNames().size(); ++i)
127 {
128 if (i > 0)
129 p << '&';
130
131 auto val = url.getParameterValues()[i];
132
133 p << URL::addEscapeChars (url.getParameterNames()[i], true);
134
135 if (val.isNotEmpty())
136 p << '=' << URL::addEscapeChars (val, true);
137 }
138
139 return p;
140 }
141
142 static int findEndOfScheme (const String& url)
143 {
144 int i = 0;
145
147 || url[i] == '+' || url[i] == '-' || url[i] == '.')
148 ++i;
149
150 return url.substring (i).startsWith ("://") ? i + 1 : 0;
151 }
152
153 static int findStartOfNetLocation (const String& url)
154 {
155 int start = findEndOfScheme (url);
156
157 while (url[start] == '/')
158 ++start;
159
160 return start;
161 }
162
163 static int findStartOfPath (const String& url)
164 {
165 return url.indexOfChar (findStartOfNetLocation (url), '/') + 1;
166 }
167
168 static void concatenatePaths (String& path, const String& suffix)
169 {
170 if (! path.endsWithChar ('/'))
171 path << '/';
172
173 if (suffix.startsWithChar ('/'))
174 path += suffix.substring (1);
175 else
176 path += suffix;
177 }
178
180 {
181 auto startOfPath = findStartOfPath (url);
182 auto lastSlash = url.lastIndexOfChar ('/');
183
184 if (lastSlash > startOfPath && lastSlash == url.length() - 1)
186
187 if (lastSlash < 0)
188 return url;
189
190 return url.substring (0, std::max (startOfPath, lastSlash));
191 }
192}
193
195{
196 parameterNames.add (name);
198}
199
200String URL::toString (bool includeGetParameters) const
201{
202 if (includeGetParameters)
203 return url + getQueryString();
204
205 return url;
206}
207
209{
210 return url.isEmpty();
211}
212
214{
215 //xxx TODO
216 return url.isNotEmpty();
217}
218
220{
221 return getDomainInternal (false);
222}
223
224String URL::getSubPath (bool includeGetParameters) const
225{
226 auto startOfPath = URLHelpers::findStartOfPath (url);
227 auto subPath = startOfPath <= 0 ? String()
228 : url.substring (startOfPath);
229
230 if (includeGetParameters)
231 subPath += getQueryString();
232
233 return subPath;
234}
235
237{
238 if (parameterNames.size() > 0)
239 return "?" + URLHelpers::getMangledParameters (*this);
240
241 return {};
242}
243
245{
246 return url.substring (0, URLHelpers::findEndOfScheme (url) - 1);
247}
248
249#if ! JUCE_ANDROID
251{
252 return getScheme() == "file";
253}
254
256{
257 return fileFromFileSchemeURL (*this);
258}
259
261{
262 return toString (false).fromLastOccurrenceOf ("/", false, true);
263}
264#endif
265
270
272{
273 if (! fileURL.isLocalFile())
274 {
276 return {};
277 }
278
279 auto path = removeEscapeChars (fileURL.getDomainInternal (true)).replace ("+", "%2B");
280
281 #if JUCE_WINDOWS
282 bool isUncPath = (! fileURL.url.startsWith ("file:///"));
283 #else
284 path = File::getSeparatorString() + path;
285 #endif
286
287 auto urlElements = StringArray::fromTokens (fileURL.getSubPath(), "/", "");
288
289 for (auto urlElement : urlElements)
290 path += File::getSeparatorString() + removeEscapeChars (urlElement.replace ("+", "%2B"));
291
292 #if JUCE_WINDOWS
293 if (isUncPath)
294 path = "\\\\" + path;
295 #endif
296
297 return path;
298}
299
300int URL::getPort() const
301{
302 auto colonPos = url.indexOfChar (URLHelpers::findStartOfNetLocation (url), ':');
303
304 return colonPos > 0 ? url.substring (colonPos + 1).getIntValue() : 0;
305}
306
308{
309 URL u (*this);
310 u.url = newURL;
311 return u;
312}
313
314URL URL::withNewSubPath (const String& newPath) const
315{
316 URL u (*this);
317
318 auto startOfPath = URLHelpers::findStartOfPath (url);
319
320 if (startOfPath > 0)
321 u.url = url.substring (0, startOfPath);
322
323 URLHelpers::concatenatePaths (u.url, newPath);
324 return u;
325}
326
328{
329 URL u (*this);
331 return u;
332}
333
334URL URL::getChildURL (const String& subPath) const
335{
336 URL u (*this);
337 URLHelpers::concatenatePaths (u.url, subPath);
338 return u;
339}
340
342{
343 return filesToUpload.size() > 0 || ! postData.isEmpty();
344}
345
347 MemoryBlock& postDataToWrite,
348 bool addParametersToBody) const
349{
350 MemoryOutputStream data (postDataToWrite, false);
351
352 if (filesToUpload.size() > 0)
353 {
354 // (this doesn't currently support mixing custom post-data with uploads..)
355 jassert (postData.isEmpty());
356
357 auto boundary = String::toHexString (Random::getSystemRandom().nextInt64());
358
359 headers << "Content-Type: multipart/form-data; boundary=" << boundary << "\r\n";
360
361 data << "--" << boundary;
362
363 for (int i = 0; i < parameterNames.size(); ++i)
364 {
365 data << "\r\nContent-Disposition: form-data; name=\"" << parameterNames[i]
366 << "\"\r\n\r\n" << parameterValues[i]
367 << "\r\n--" << boundary;
368 }
369
370 for (auto* f : filesToUpload)
371 {
372 data << "\r\nContent-Disposition: form-data; name=\"" << f->parameterName
373 << "\"; filename=\"" << f->filename << "\"\r\n";
374
375 if (f->mimeType.isNotEmpty())
376 data << "Content-Type: " << f->mimeType << "\r\n";
377
378 data << "Content-Transfer-Encoding: binary\r\n\r\n";
379
380 if (f->data != nullptr)
381 data << *f->data;
382 else
383 data << f->file;
384
385 data << "\r\n--" << boundary;
386 }
387
388 data << "--\r\n";
389 }
390 else
391 {
392 if (addParametersToBody)
394
395 data << postData;
396
397 // if the user-supplied headers didn't contain a content-type, add one now..
398 if (! headers.containsIgnoreCase ("Content-Type"))
399 headers << "Content-Type: application/x-www-form-urlencoded\r\n";
400
401 headers << "Content-length: " << (int) data.getDataSize() << "\r\n";
402 }
403}
404
405//==============================================================================
406bool URL::isProbablyAWebsiteURL (const String& possibleURL)
407{
408 for (auto* protocol : { "http:", "https:", "ftp:" })
409 if (possibleURL.startsWithIgnoreCase (protocol))
410 return true;
411
412 if (possibleURL.containsChar ('@') || possibleURL.containsChar (' '))
413 return false;
414
415 auto topLevelDomain = possibleURL.upToFirstOccurrenceOf ("/", false, false)
416 .fromLastOccurrenceOf (".", false, false);
417
418 return topLevelDomain.isNotEmpty() && topLevelDomain.length() <= 3;
419}
420
421bool URL::isProbablyAnEmailAddress (const String& possibleEmailAddress)
422{
423 auto atSign = possibleEmailAddress.indexOfChar ('@');
424
425 return atSign > 0
426 && possibleEmailAddress.lastIndexOfChar ('.') > (atSign + 1)
427 && ! possibleEmailAddress.endsWithChar ('.');
428}
429
430String URL::getDomainInternal (bool ignorePort) const
431{
433 auto end1 = url.indexOfChar (start, '/');
434 auto end2 = ignorePort ? -1 : url.indexOfChar (start, ':');
435
436 auto end = (end1 < 0 && end2 < 0) ? std::numeric_limits<int>::max()
437 : ((end1 < 0 || end2 < 0) ? jmax (end1, end2)
438 : jmin (end1, end2));
439 return url.substring (start, end);
440}
441
442#if JUCE_IOS
443URL::Bookmark::Bookmark (void* bookmarkToUse) : data (bookmarkToUse)
444{
445}
446
447URL::Bookmark::~Bookmark()
448{
449 [(NSData*) data release];
450}
451
452void setURLBookmark (URL& u, void* bookmark)
453{
454 u.bookmark = new URL::Bookmark (bookmark);
455}
456
457void* getURLBookmark (URL& u)
458{
459 if (u.bookmark.get() == nullptr)
460 return nullptr;
461
462 return u.bookmark.get()->data;
463}
464
465template <typename Stream> struct iOSFileStreamWrapperFlush { static void flush (Stream*) {} };
466template <> struct iOSFileStreamWrapperFlush<FileOutputStream> { static void flush (OutputStream* o) { o->flush(); } };
467
468template <typename Stream>
469class iOSFileStreamWrapper : public Stream
470{
471public:
472 iOSFileStreamWrapper (URL& urlToUse)
473 : Stream (getLocalFileAccess (urlToUse)),
474 url (urlToUse)
475 {}
476
477 ~iOSFileStreamWrapper()
478 {
479 iOSFileStreamWrapperFlush<Stream>::flush (this);
480
481 if (NSData* bookmark = (NSData*) getURLBookmark (url))
482 {
483 BOOL isBookmarkStale = false;
484 NSError* error = nil;
485
486 auto nsURL = [NSURL URLByResolvingBookmarkData: bookmark
487 options: 0
488 relativeToURL: nil
489 bookmarkDataIsStale: &isBookmarkStale
490 error: &error];
491
492 if (error == nil)
493 {
494 if (isBookmarkStale)
495 updateStaleBookmark (nsURL, url);
496
497 [nsURL stopAccessingSecurityScopedResource];
498 }
499 else
500 {
501 auto desc = [error localizedDescription];
502 ignoreUnused (desc);
504 }
505 }
506 }
507
508private:
509 URL url;
510 bool securityAccessSucceeded = false;
511
512 File getLocalFileAccess (URL& urlToUse)
513 {
514 if (NSData* bookmark = (NSData*) getURLBookmark (urlToUse))
515 {
516 BOOL isBookmarkStale = false;
517 NSError* error = nil;
518
519 auto nsURL = [NSURL URLByResolvingBookmarkData: bookmark
520 options: 0
521 relativeToURL: nil
522 bookmarkDataIsStale: &isBookmarkStale
523 error: &error];
524
525 if (error == nil)
526 {
527 securityAccessSucceeded = [nsURL startAccessingSecurityScopedResource];
528
529 if (isBookmarkStale)
530 updateStaleBookmark (nsURL, urlToUse);
531
532 return urlToUse.getLocalFile();
533 }
534
535 auto desc = [error localizedDescription];
536 ignoreUnused (desc);
538 }
539
540 return urlToUse.getLocalFile();
541 }
542
543 void updateStaleBookmark (NSURL* nsURL, URL& juceUrl)
544 {
545 NSError* error = nil;
546
547 NSData* bookmark = [nsURL bookmarkDataWithOptions: NSURLBookmarkCreationSuitableForBookmarkFile
548 includingResourceValuesForKeys: nil
549 relativeToURL: nil
550 error: &error];
551
552 if (error == nil)
553 setURLBookmark (juceUrl, (void*) bookmark);
554 else
556 }
557};
558#endif
559//==============================================================================
560template <typename Member, typename Item>
561static URL::InputStreamOptions with (URL::InputStreamOptions options, Member&& member, Item&& item)
562{
563 options.*member = std::forward<Item> (item);
564 return options;
565}
566
568
570{
571 return with (*this, &InputStreamOptions::progressCallback, std::move (cb));
572}
573
578
583
588
593
598
603
604//==============================================================================
605std::unique_ptr<InputStream> URL::createInputStream (const InputStreamOptions& options) const
606{
607 if (isLocalFile())
608 {
609 #if JUCE_IOS
610 // We may need to refresh the embedded bookmark.
611 return std::make_unique<iOSFileStreamWrapper<FileInputStream>> (const_cast<URL&> (*this));
612 #else
613 return getLocalFile().createInputStream();
614 #endif
615 }
616
617 return nullptr;
618}
619
620std::unique_ptr<OutputStream> URL::createOutputStream() const
621{
622 if (isLocalFile())
623 {
624 #if JUCE_IOS
625 // We may need to refresh the embedded bookmark.
626 return std::make_unique<iOSFileStreamWrapper<FileOutputStream>> (const_cast<URL&> (*this));
627 #else
628 return std::make_unique<FileOutputStream> (getLocalFile());
629 #endif
630 }
631
632 return nullptr;
633}
634
635//==============================================================================
636bool URL::readEntireBinaryStream (MemoryBlock& destData, bool usePostCommand) const
637{
638 const std::unique_ptr<InputStream> in (isLocalFile() ? getLocalFile().createInputStream()
639 : createInputStream (InputStreamOptions (toHandling (usePostCommand))));
640
641 if (in != nullptr)
642 {
643 in->readIntoMemoryBlock (destData);
644 return true;
645 }
646
647 return false;
648}
649
650String URL::readEntireTextStream (bool usePostCommand) const
651{
652 const std::unique_ptr<InputStream> in (isLocalFile() ? getLocalFile().createInputStream()
653 : createInputStream (InputStreamOptions (toHandling (usePostCommand))));
654
655 if (in != nullptr)
656 return in->readEntireStreamAsString();
657
658 return {};
659}
660
661std::unique_ptr<XmlElement> URL::readEntireXmlStream (bool usePostCommand) const
662{
663 return parseXML (readEntireTextStream (usePostCommand));
664}
665
666//==============================================================================
667URL URL::withParameter (const String& parameterName,
668 const String& parameterValue) const
669{
670 auto u = *this;
671 u.addParameter (parameterName, parameterValue);
672 return u;
673}
674
675URL URL::withParameters (const StringPairArray& parametersToAdd) const
676{
677 auto u = *this;
678
679 for (int i = 0; i < parametersToAdd.size(); ++i)
680 u.addParameter (parametersToAdd.getAllKeys()[i],
681 parametersToAdd.getAllValues()[i]);
682
683 return u;
684}
685
686URL URL::withPOSTData (const String& newPostData) const
687{
688 return withPOSTData (MemoryBlock (newPostData.toRawUTF8(), newPostData.getNumBytesAsUTF8()));
689}
690
691URL URL::withPOSTData (const MemoryBlock& newPostData) const
692{
693 auto u = *this;
694 u.postData = newPostData;
695 return u;
696}
697
698URL::Upload::Upload (const String& param, const String& name,
699 const String& mime, const File& f, MemoryBlock* mb)
700 : parameterName (param), filename (name), mimeType (mime), file (f), data (mb)
701{
702 jassert (mimeType.isNotEmpty()); // You need to supply a mime type!
703}
704
706{
707 auto u = *this;
708
709 for (int i = u.filesToUpload.size(); --i >= 0;)
710 if (u.filesToUpload.getObjectPointerUnchecked (i)->parameterName == f->parameterName)
711 u.filesToUpload.remove (i);
712
713 u.filesToUpload.add (f);
714 return u;
715}
716
717URL URL::withFileToUpload (const String& parameterName, const File& fileToUpload,
718 const String& mimeType) const
719{
720 return withUpload (new Upload (parameterName, fileToUpload.getFileName(),
721 mimeType, fileToUpload, nullptr));
722}
723
724URL URL::withDataToUpload (const String& parameterName, const String& filename,
725 const MemoryBlock& fileContentToUpload, const String& mimeType) const
726{
727 return withUpload (new Upload (parameterName, filename, mimeType, File(),
728 new MemoryBlock (fileContentToUpload)));
729}
730
731//==============================================================================
733{
734 auto result = s.replaceCharacter ('+', ' ');
735
736 if (! result.containsChar ('%'))
737 return result;
738
739 // We need to operate on the string as raw UTF8 chars, and then recombine them into unicode
740 // after all the replacements have been made, so that multi-byte chars are handled.
741 Array<char> utf8 (result.toRawUTF8(), (int) result.getNumBytesAsUTF8());
742
743 for (int i = 0; i < utf8.size(); ++i)
744 {
745 if (utf8.getUnchecked(i) == '%')
746 {
747 auto hexDigit1 = CharacterFunctions::getHexDigitValue ((juce_wchar) (uint8) utf8 [i + 1]);
748 auto hexDigit2 = CharacterFunctions::getHexDigitValue ((juce_wchar) (uint8) utf8 [i + 2]);
749
750 if (hexDigit1 >= 0 && hexDigit2 >= 0)
751 {
752 utf8.set (i, (char) ((hexDigit1 << 4) + hexDigit2));
753 utf8.removeRange (i + 1, 2);
754 }
755 }
756 }
757
758 return String::fromUTF8 (utf8.getRawDataPointer(), utf8.size());
759}
760
761String URL::addEscapeChars (const String& s, bool isParameter, bool roundBracketsAreLegal)
762{
763 String legalChars (isParameter ? "_-.~"
764 : ",$_-.*!'");
765
766 if (roundBracketsAreLegal)
767 legalChars += "()";
768
769 Array<char> utf8 (s.toRawUTF8(), (int) s.getNumBytesAsUTF8());
770
771 for (int i = 0; i < utf8.size(); ++i)
772 {
773 auto c = utf8.getUnchecked(i);
774
776 || legalChars.containsChar ((juce_wchar) c)))
777 {
778 utf8.set (i, '%');
779 utf8.insert (++i, "0123456789ABCDEF" [((uint8) c) >> 4]);
780 utf8.insert (++i, "0123456789ABCDEF" [c & 15]);
781 }
782 }
783
784 return String::fromUTF8 (utf8.getRawDataPointer(), utf8.size());
785}
786
787//==============================================================================
789{
790 auto u = toString (true);
791
792 if (u.containsChar ('@') && ! u.containsChar (':'))
793 u = "mailto:" + u;
794
795 return Process::openDocument (u, {});
796}
797
798//==============================================================================
799std::unique_ptr<InputStream> URL::createInputStream (bool usePostCommand,
801 void* context,
802 String headers,
803 int timeOutMs,
804 StringPairArray* responseHeaders,
805 int* statusCode,
806 int numRedirectsToFollow,
807 String httpRequestCmd) const
808{
809 std::function<bool (int, int)> callback;
810
811 if (cb != nullptr)
812 callback = [context, cb] (int sent, int total) { return cb (context, sent, total); };
813
814 return createInputStream (InputStreamOptions (toHandling (usePostCommand))
815 .withProgressCallback (std::move (callback))
816 .withExtraHeaders (headers)
817 .withConnectionTimeoutMs (timeOutMs)
818 .withResponseHeaders (responseHeaders)
819 .withStatusCode (statusCode)
820 .withNumRedirectsToFollow(numRedirectsToFollow)
821 .withHttpRequestCmd (httpRequestCmd));
822}
823
824std::unique_ptr<URL::DownloadTask> URL::downloadToFile (const File& targetLocation,
825 String extraHeaders,
826 DownloadTask::Listener* listener,
827 bool usePostCommand)
828{
829 return nullptr;
830}
831
832} // namespace juce
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
Type jmax(const Type a, const Type b)
Definition MathsFunctions.h:48
#define noexcept
Definition DistrhoDefines.h:72
static StringArray fromTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Definition StringArray.cpp:369
static String toHexString(int number)
Definition String.cpp:1830
static String fromUTF8(const char *utf8buffer, int bufferSizeBytes=-1)
Definition String.cpp:1961
Definition juce_Array.h:56
ElementType getUnchecked(int index) const
Definition juce_Array.h:252
int size() const noexcept
Definition juce_Array.h:215
void removeRange(int startIndex, int numberToRemove)
Definition juce_Array.h:919
void insert(int indexToInsertAt, ParameterType newElement)
Definition juce_Array.h:462
ElementType * getRawDataPointer() noexcept
Definition juce_Array.h:310
void set(int indexToChange, ParameterType newValue)
Definition juce_Array.h:542
static int getHexDigitValue(juce_wchar digit) noexcept
Definition juce_CharacterFunctions.cpp:112
static bool isLetterOrDigit(char character) noexcept
Definition juce_CharacterFunctions.cpp:90
Definition juce_File.h:45
static StringRef getSeparatorString()
Definition juce_posix_SharedCode.h:114
const String & getFullPathName() const noexcept
Definition juce_File.h:153
String getFileName() const
Definition juce_File.cpp:364
bool isRoot() const
Definition juce_File.cpp:125
File getParentDirectory() const
Definition juce_File.cpp:358
Definition juce_MemoryBlock.h:33
Definition juce_MemoryOutputStream.h:36
static bool JUCE_CALLTYPE openDocument(const String &documentURL, const String &parameters)
Definition juce_linux_Files.cpp:200
static Random & getSystemRandom() noexcept
Definition juce_Random.cpp:67
int size() const noexcept
Definition juce_StringArray.h:136
Definition juce_String.h:53
int indexOfChar(juce_wchar characterToLookFor) const noexcept
Definition juce_String.cpp:874
String upToFirstOccurrenceOf(StringRef substringToEndWith, bool includeSubStringInResult, bool ignoreCase) const
Definition juce_String.cpp:1585
int length() const noexcept
Definition juce_String.cpp:511
bool endsWithChar(juce_wchar character) const noexcept
Definition juce_String.cpp:1410
const char * toRawUTF8() const
Definition juce_String.cpp:2074
bool containsIgnoreCase(StringRef text) const noexcept
Definition juce_String.cpp:1045
bool startsWithChar(juce_wchar character) const noexcept
Definition juce_String.cpp:1403
bool startsWith(StringRef text) const noexcept
Definition juce_String.cpp:1393
bool containsChar(juce_wchar character) const noexcept
Definition juce_String.cpp:1040
bool startsWithIgnoreCase(StringRef text) const noexcept
Definition juce_String.cpp:1398
size_t getNumBytesAsUTF8() const noexcept
Definition juce_String.cpp:2120
String dropLastCharacters(int numberToDrop) const
Definition juce_String.cpp:1555
int lastIndexOfChar(juce_wchar character) const noexcept
Definition juce_String.cpp:899
String substring(int startIndex, int endIndex) const
Definition juce_String.cpp:1498
String fromLastOccurrenceOf(StringRef substringToFind, bool includeSubStringInResult, bool ignoreCase) const
Definition juce_String.cpp:1575
bool isNotEmpty() const noexcept
Definition juce_String.h:316
Definition juce_StringPairArray.h:35
const StringArray & getAllValues() const noexcept
Definition juce_StringPairArray.h:90
int size() const noexcept
Definition juce_StringPairArray.h:93
const StringArray & getAllKeys() const noexcept
Definition juce_StringPairArray.h:87
DownloadTaskListener Listener
Definition juce_URL.h:493
Definition juce_URL.h:322
std::function< bool(int, int)> progressCallback
Definition juce_URL.h:391
const ParameterHandling parameterHandling
Definition juce_URL.h:389
String extraHeaders
Definition juce_URL.h:392
int * statusCode
Definition juce_URL.h:395
JUCE_NODISCARD InputStreamOptions withExtraHeaders(const String &extraHeaders) const
Definition juce_URL.cpp:574
int connectionTimeOutMs
Definition juce_URL.h:393
JUCE_NODISCARD InputStreamOptions withResponseHeaders(StringPairArray *responseHeaders) const
Definition juce_URL.cpp:584
JUCE_NODISCARD InputStreamOptions withStatusCode(int *statusCode) const
Definition juce_URL.cpp:589
JUCE_NODISCARD InputStreamOptions withNumRedirectsToFollow(int numRedirectsToFollow) const
Definition juce_URL.cpp:594
int numRedirectsToFollow
Definition juce_URL.h:396
JUCE_NODISCARD InputStreamOptions withConnectionTimeoutMs(int connectionTimeoutMs) const
Definition juce_URL.cpp:579
String httpRequestCmd
Definition juce_URL.h:397
InputStreamOptions(ParameterHandling parameterHandling)
Definition juce_URL.cpp:567
JUCE_NODISCARD InputStreamOptions withProgressCallback(std::function< bool(int bytesSent, int totalBytes)> progressCallback) const
Definition juce_URL.cpp:569
JUCE_NODISCARD InputStreamOptions withHttpRequestCmd(const String &httpRequestCmd) const
Definition juce_URL.cpp:599
StringPairArray * responseHeaders
Definition juce_URL.h:394
Definition juce_URL.h:38
JUCE_NODISCARD URL withParameter(const String &parameterName, const String &parameterValue) const
Definition juce_URL.cpp:667
static URL createWithoutParsing(const String &url)
Definition juce_URL.cpp:100
File getLocalFile() const
Definition juce_URL.cpp:255
bool isWellFormed() const
Definition juce_URL.cpp:213
bool readEntireBinaryStream(MemoryBlock &destData, bool usePostCommand=false) const
Definition juce_URL.cpp:636
int getPort() const
Definition juce_URL.cpp:300
URL withUpload(Upload *) const
Definition juce_URL.cpp:705
JUCE_NODISCARD URL withDataToUpload(const String &parameterName, const String &filename, const MemoryBlock &fileContentToUpload, const String &mimeType) const
Definition juce_URL.cpp:724
String getFileName() const
Definition juce_URL.cpp:260
URL getChildURL(const String &subPath) const
Definition juce_URL.cpp:334
static String removeEscapeChars(const String &stringToRemoveEscapeCharsFrom)
Definition juce_URL.cpp:732
static String addEscapeChars(const String &stringToAddEscapeCharsTo, bool isParameter, bool roundBracketsAreLegal=true)
Definition juce_URL.cpp:761
ParameterHandling
Definition juce_URL.h:302
@ inPostData
Definition juce_URL.h:304
@ inAddress
Definition juce_URL.h:303
String toString(bool includeGetParameters) const
Definition juce_URL.cpp:200
std::unique_ptr< OutputStream > createOutputStream() const
Definition juce_URL.cpp:620
String getSubPath(bool includeGetParameters=false) const
Definition juce_URL.cpp:224
URL getParentURL() const
Definition juce_URL.cpp:327
String getDomainInternal(bool) const
Definition juce_URL.cpp:430
String getQueryString() const
Definition juce_URL.cpp:236
ReferenceCountedArray< Upload > filesToUpload
Definition juce_URL.h:727
JUCE_NODISCARD URL withNewSubPath(const String &newPath) const
Definition juce_URL.cpp:314
static File fileFromFileSchemeURL(const URL &)
Definition juce_URL.cpp:271
static bool isProbablyAnEmailAddress(const String &possibleEmailAddress)
Definition juce_URL.cpp:421
JUCE_NODISCARD URL withNewDomainAndPath(const String &newFullPath) const
Definition juce_URL.cpp:307
String readEntireTextStream(bool usePostCommand=false) const
Definition juce_URL.cpp:650
bool isEmpty() const noexcept
Definition juce_URL.cpp:208
static bool isProbablyAWebsiteURL(const String &possibleURL)
Definition juce_URL.cpp:406
std::unique_ptr< InputStream > createInputStream(const InputStreamOptions &options) const
Definition juce_URL.cpp:605
const StringArray & getParameterValues() const noexcept
Definition juce_URL.h:254
std::unique_ptr< DownloadTask > downloadToFile(const File &targetLocation, String extraHeaders=String(), DownloadTaskListener *listener=nullptr, bool usePostCommand=false)
Definition juce_URL.cpp:824
bool(void *context, int bytesSent, int totalBytes) OpenStreamProgressCallback
Definition juce_URL.h:660
String getDomain() const
Definition juce_URL.cpp:219
static ParameterHandling toHandling(bool)
Definition juce_URL.cpp:266
bool isLocalFile() const
Definition juce_URL.cpp:250
void addParameter(const String &, const String &)
Definition juce_URL.cpp:194
JUCE_NODISCARD URL withFileToUpload(const String &parameterName, const File &fileToUpload, const String &mimeType) const
Definition juce_URL.cpp:717
JUCE_NODISCARD URL withPOSTData(const String &postData) const
Definition juce_URL.cpp:686
bool hasBodyDataToSend() const
Definition juce_URL.cpp:341
JUCE_NODISCARD URL withParameters(const StringPairArray &parametersToAdd) const
Definition juce_URL.cpp:675
void createHeadersAndPostData(String &, MemoryBlock &, bool) const
Definition juce_URL.cpp:346
const StringArray & getParameterNames() const noexcept
Definition juce_URL.h:240
String url
Definition juce_URL.h:723
std::unique_ptr< XmlElement > readEntireXmlStream(bool usePostCommand=false) const
Definition juce_URL.cpp:661
StringArray parameterValues
Definition juce_URL.h:725
String getScheme() const
Definition juce_URL.cpp:244
bool launchInDefaultBrowser() const
Definition juce_URL.cpp:788
MemoryBlock postData
Definition juce_URL.h:724
void init()
Definition juce_URL.cpp:68
URL()
Definition juce_URL.cpp:27
StringArray parameterNames
Definition juce_URL.h:725
struct huft * u[BMAX]
Definition inflate.c:1583
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
unsigned f
Definition inflate.c:1572
static char filename[]
Definition features.c:5
static PuglViewHint int value
Definition pugl.h:1708
static double timeout
Definition pugl.h:1799
static const char * name
Definition pugl.h:1582
virtual ASIOError start()=0
int val
Definition jpeglib.h:956
JSAMPIMAGE data
Definition jpeglib.h:945
#define jassert(expression)
#define jassertfalse
float in
Definition lilv_test.c:1460
Definition juce_URL.cpp:120
static String removeLastPathSection(const String &url)
Definition juce_URL.cpp:179
static int findEndOfScheme(const String &url)
Definition juce_URL.cpp:142
static int findStartOfPath(const String &url)
Definition juce_URL.cpp:163
static int findStartOfNetLocation(const String &url)
Definition juce_URL.cpp:153
static void concatenatePaths(String &path, const String &suffix)
Definition juce_URL.cpp:168
static String getMangledParameters(const URL &url)
Definition juce_URL.cpp:121
Definition carla_juce.cpp:31
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Definition juce_RangedDirectoryIterator.h:184
wchar_t juce_wchar
Definition juce_CharacterFunctions.h:42
std::unique_ptr< XmlElement > parseXML(const String &textToParse)
Definition juce_XmlDocument.cpp:41
void ignoreUnused(Types &&...) noexcept
Definition juce_MathsFunctions.h:333
static URL::InputStreamOptions with(URL::InputStreamOptions options, Member &&member, Item &&item)
Definition juce_URL.cpp:561
unsigned char uint8
Definition juce_MathsFunctions.h:37
Definition juce_URL.h:699
String mimeType
Definition juce_URL.h:701
String parameterName
Definition juce_URL.h:701
Upload(const String &, const String &, const String &, const File &, MemoryBlock *)
Definition juce_URL.cpp:698
File file
Definition juce_URL.h:702
String filename
Definition juce_URL.h:701
std::unique_ptr< MemoryBlock > data
Definition juce_URL.h:703
RECT const char void(* callback)(const char *droppath))) SWELL_API_DEFINE(BOOL
Definition swell-functions.h:1004
signed char BOOL
Definition swell-types.h:160
uch * p
Definition crypt.c:594
return c
Definition crypt.c:175
int error
Definition extract.c:1038
ZCONST uch * init
Definition extract.c:2392
ulg size
Definition extract.c:2350
int flush(__G__ rawbuf, size, unshrink) __GDEF uch *rawbuf
int result
Definition process.c:1455
typedef int(UZ_EXP MsgFn)()
#define const
Definition zconf.h:137