summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-06-17 08:09:45 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-06-17 08:09:45 (GMT)
commitc4b4eeee2433c3b16ed9390d1b7487c2c98aaee3 (patch)
treeaf40d7ef542d9da2f5e7da359ae4d7ffcae5a95b /Swiften
parent334d96a441635113c761534007912a4963cb0e13 (diff)
downloadswift-c4b4eeee2433c3b16ed9390d1b7487c2c98aaee3.zip
swift-c4b4eeee2433c3b16ed9390d1b7487c2c98aaee3.tar.bz2
Fixed potential uncaught exception in HTTPConnectProxiedConnection.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Network/HTTPConnectProxiedConnection.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/Swiften/Network/HTTPConnectProxiedConnection.cpp b/Swiften/Network/HTTPConnectProxiedConnection.cpp
index 7bd7e41..a88ded1 100644
--- a/Swiften/Network/HTTPConnectProxiedConnection.cpp
+++ b/Swiften/Network/HTTPConnectProxiedConnection.cpp
@@ -61,14 +61,24 @@ void HTTPConnectProxiedConnection::initializeProxy() {
void HTTPConnectProxiedConnection::handleProxyInitializeData(boost::shared_ptr<SafeByteArray> data) {
SWIFT_LOG(debug) << byteArrayToString(ByteArray(data->begin(), data->end())) << std::endl;
std::vector<std::string> tmp = String::split(byteArrayToString(ByteArray(data->begin(), data->end())), ' ');
- if(tmp.size() > 1) {
- int status = boost::lexical_cast<int> (tmp[1].c_str());
- SWIFT_LOG(debug) << "Proxy Status: " << status << std::endl;
- if (status / 100 == 2) { // all 2XX states are OK
- setProxyInitializeFinished(true);
- return;
+ if (tmp.size() > 1) {
+ try {
+ int status = boost::lexical_cast<int>(tmp[1]);
+ SWIFT_LOG(debug) << "Proxy Status: " << status << std::endl;
+ if (status / 100 == 2) { // all 2XX states are OK
+ setProxyInitializeFinished(true);
+ }
+ else {
+ SWIFT_LOG(debug) << "HTTP Proxy returned an error: " << byteArrayToString(ByteArray(data->begin(), data->end())) << std::endl;
+ setProxyInitializeFinished(false);
+ }
}
- SWIFT_LOG(debug) << "HTTP Proxy returned an error: " << byteArrayToString(ByteArray(data->begin(), data->end())) << std::endl;
+ catch (boost::bad_lexical_cast&) {
+ SWIFT_LOG(warning) << "Unexpected response: " << tmp[1] << std::endl;
+ setProxyInitializeFinished(false);
+ }
+ }
+ else {
+ setProxyInitializeFinished(false);
}
- setProxyInitializeFinished(false);
}