If I run the following code in a freshly created Console Application on OSX I always crash on quit (so after the return 0
line, in a different thread than the main thread.
This code is adapted from JuceDemo.
int main (int argc, char* argv[])
{
URL url {"https://www.google.com"};
StringPairArray responseHeaders;
int statusCode = 0;
ScopedPointer<InputStream> stream ( url.createInputStream (false, nullptr, nullptr, String(), 10000, &responseHeaders, &statusCode) );
if (stream != nullptr)
{
String result = stream->readEntireStreamAsString();
DBG( (statusCode != 0 ? "Status code: " + String (statusCode) + newLine : String())
+ "Response headers: " + newLine
+ responseHeaders.getDescription() + newLine
+ "----------------------------------------------------" + newLine
+ result );
}
else if (statusCode != 0)
{
DBG( "Failed to connect, status code = " + String (statusCode) );
}
else DBG( "Failed to connect!" );
return 0;
}
Anyone any insights?