← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2958: Fix HTTP redirections

 

------------------------------------------------------------
revno: 2958
committer: eMTee <emtee11@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Thu 2012-06-21 19:55:45 +0200
message:
  Fix HTTP redirections
modified:
  changelog.txt
  dcpp/HttpConnection.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2012-06-18 16:32:14 +0000
+++ changelog.txt	2012-06-21 17:55:45 +0000
@@ -13,6 +13,10 @@
 * Do not automatch queue for bad/removed sources (emtee)
 * Minor DL queue tab fixes (poy)
 * Replace the slot up-down control by a context menu (poy)
+* [L#733381] Add protocol debug window (bigmuscle, iceman50)
+* [L#745162] Fix upload log format for partial lists (emtee)
+* Fix GUI problems in a download attempt of a public hublist with invalid address (emtee)
+* Fix unsuccessful HTTP redirections (emtee)
 
 -- 0.799 2012-05-05 --
 * Add icons (iceman50)

=== modified file 'dcpp/HttpConnection.cpp'
--- dcpp/HttpConnection.cpp	2012-01-13 20:55:20 +0000
+++ dcpp/HttpConnection.cpp	2012-06-21 17:55:45 +0000
@@ -24,6 +24,8 @@
 #include "SettingsManager.h"
 #include "version.h"
 
+#include <boost/algorithm/string/trim.hpp>
+
 namespace dcpp {
 
 static const std::string CORAL_SUFFIX = ".nyud.net";
@@ -55,12 +57,9 @@
 void HttpConnection::downloadFile(const string& aUrl) {
 	dcassert(Util::findSubString(aUrl, "http://";) == 0);
 	currentUrl = aUrl;
-	// Trim spaces
-	while(currentUrl[0] == ' ')
-		currentUrl.erase(0, 1);
-	while(currentUrl[currentUrl.length() - 1] == ' ') {
-		currentUrl.erase(currentUrl.length()-1);
-	}
+	// Trim whitespaces
+	boost::algorithm::trim(currentUrl);
+
 	// reset all settings (as in constructor), moved here from onLine(302) because ok was not reset properly
 	moved302 = false;
 	ok = false;
@@ -156,7 +155,10 @@
 		BufferedSocket::putSocket(socket);
 		socket = NULL;
 
-		string location302 = aLine.substr(10, aLine.length() - 11);
+		string location302 = aLine.substr(10, aLine.length() - 10);
+		// shave off any sort of line endings - some servers reportedly even omit it
+		boost::algorithm::trim(location302);
+
 		// make sure we can also handle redirects with relative paths
 		if(Util::strnicmp(location302.c_str(), "http://";, 7) != 0) {
 			if(location302[0] == '/') {