accept urls without trailing '/'

This commit is contained in:
john30
2018-02-04 16:18:10 +01:00
parent cf05b63aa3
commit f2f70d400a
+10 -6
View File
@@ -20,7 +20,6 @@
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <ios>
namespace ebusd {
@@ -40,13 +39,18 @@ bool HttpClient::parseUrl(const string& url, string& proto, string& host, uint16
return false;
}
size_t pos = url.find('/', hostPos);
if (pos == string::npos || pos == hostPos) {
if (pos == hostPos) {
return false;
}
host = url.substr(hostPos, pos - hostPos);
uri = url.substr(pos);
if (uri[uri.length()-1] != '/') {
uri += "/";
if (pos == string::npos) {
host = url.substr(hostPos);
uri = "/";
} else {
host = url.substr(hostPos, pos - hostPos);
uri = url.substr(pos);
if (uri[uri.length()-1] != '/') {
uri += "/";
}
}
pos = host.find(':');
if (pos == 0) {