Skip to content

Commit d678090

Browse files
committed
Handle & report HTTP request failed error when downloading a plugin
1 parent 29f0248 commit d678090

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

Source/UI/PluginInstaller.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,14 @@ void PluginInfoComponent::run()
11081108

11091109
LOGE("Error.. Plugin already in use. Please remove it from the signal chain and try again.");
11101110
}
1111+
else if(dlReturnCode == HTTP_ERR)
1112+
{
1113+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon,
1114+
"[Plugin Installer] " + pInfo.displayName,
1115+
"HTTP request failed!!\nPlease check your internet connection...");
1116+
1117+
LOGE("HTTP request failed!! Please check your internet connection...");
1118+
}
11111119

11121120
}
11131121

@@ -1308,24 +1316,16 @@ int PluginInfoComponent::downloadPlugin(const String& plugin, const String& vers
13081316

13091317
String filename = plugin + "-" + osType + "_" + version + ".zip";
13101318

1311-
//Unzip plugin and install in plugins directory
1312-
//curl -L https://dl.bintray.com/$bintrayUser/$repo/$filename
1313-
13141319
URL fileUrl(fileDownloadURL);
13151320

1316-
int statusC;
1317-
StringPairArray responseHeaders;
1318-
13191321
//Create input stream from the plugin's zip file URL
1320-
std::unique_ptr<InputStream> fileStream = fileUrl.createInputStream(false, nullptr, nullptr, String(), 1000, &responseHeaders, &statusC, 5, String());
1321-
String newLocation = responseHeaders.getValue("Location", "NULL");
1322+
std::unique_ptr<InputStream> fileStream = fileUrl.createInputStream(URL::InputStreamOptions (URL::ParameterHandling::inAddress)
1323+
.withConnectionTimeoutMs (1000)
1324+
.withNumRedirectsToFollow (5));
13221325

1323-
// ZIP URL Location changed, use the new location
1324-
if(newLocation != "NULL")
1325-
{
1326-
fileUrl = newLocation;
1327-
fileStream = fileUrl.createInputStream(false);
1328-
}
1326+
// Could not retrieve data
1327+
if(!fileStream)
1328+
return 9;
13291329

13301330
// ZIP file empty, return.
13311331
if(fileStream->getTotalLength() == 0)

Source/UI/PluginInstaller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ class PluginInfoComponent : public Component,
133133
XML_WRITE_ERR,
134134
LOAD_ERR,
135135
PLUGIN_IN_USE,
136-
RECNODE_IN_USE
136+
RECNODE_IN_USE,
137+
HTTP_ERR
137138
};
138139

139140
void run() override;

0 commit comments

Comments
 (0)