accept urls without trailing '/'
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <ios>
|
|
||||||
|
|
||||||
namespace ebusd {
|
namespace ebusd {
|
||||||
|
|
||||||
@@ -40,13 +39,18 @@ bool HttpClient::parseUrl(const string& url, string& proto, string& host, uint16
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
size_t pos = url.find('/', hostPos);
|
size_t pos = url.find('/', hostPos);
|
||||||
if (pos == string::npos || pos == hostPos) {
|
if (pos == hostPos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
host = url.substr(hostPos, pos - hostPos);
|
if (pos == string::npos) {
|
||||||
uri = url.substr(pos);
|
host = url.substr(hostPos);
|
||||||
if (uri[uri.length()-1] != '/') {
|
uri = "/";
|
||||||
uri += "/";
|
} else {
|
||||||
|
host = url.substr(hostPos, pos - hostPos);
|
||||||
|
uri = url.substr(pos);
|
||||||
|
if (uri[uri.length()-1] != '/') {
|
||||||
|
uri += "/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pos = host.find(':');
|
pos = host.find(':');
|
||||||
if (pos == 0) {
|
if (pos == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user