Using URL to send an http request and retrieve the statusCode only (and the response) it fails to get the corret code returning 0 always.
Example:
URL url = getUrl();
bool usePost = isPost(url);
int statusCode = 0;
ScopedPointer<InputStream> is = url.createInputStream (usePost, null, null, String(), 0, null, &statusCode);
String response = is->readEntireStreamAsString();
DBG (String::formatted ("status code: %d, response: %s", statusCode, response));
The ouput of that code is always "status code: 0, response: ..."
I've found, only in the OSX/iOS version to have this problem and it seems to me that the cause is this piece of code (inside WebInputStream constructor in file juce_code/native/juce_mac_Network.mm line 337)
createConnection (progressCallback, progressCallbackContext);
if (responseHeaders != nullptr && connection != nullptr && connection->headers != nil)
{
statusCode = connection->statusCode;
...
}
I change it to this and it seems to work well:
createConnection (progressCallback, progressCallbackContext);
if (connection != nullptr && connection->headers != nil)
{
statusCode = connection->statusCode;
if (responseHeaders != nullptr) {
...
}
}
Let me know if I'm wrong
