Added --public-address option to HTTP output, for address overwriting

This commit is contained in:
Thulinma 2017-01-19 22:58:03 +01:00
parent 543ae0882b
commit 5000afe768
3 changed files with 75 additions and 39 deletions

View file

@ -74,11 +74,7 @@ HTTP::URL::URL(const std::string & url){
port = host;
host = "";
}
EXTREME_MSG("URL host: %s", host.c_str());
EXTREME_MSG("URL protocol: %s", protocol.c_str());
EXTREME_MSG("URL port: %s", port.c_str());
EXTREME_MSG("URL path: %s", path.c_str());
EXTREME_MSG("URL args: %s", args.c_str());
EXTREME_MSG("URL: %s", getUrl().c_str());
}
///Returns the port in numeric format
@ -87,6 +83,19 @@ uint32_t HTTP::URL::getPort() const{
return atoi(port.c_str());
}
///Returns the full URL in string format
std::string HTTP::URL::getUrl() const{
std::string ret;
if (protocol.size()){
ret = protocol + "://" + host;
}else{
ret = "//" + host;
}
if (port.size()){ret += ":" + port;}
if (path.size()){ret += "/" + path;}
return ret;
}
/// This constructor creates an empty HTTP::Parser, ready for use for either reading or writing.
/// All this constructor does is call HTTP::Parser::Clean().
HTTP::Parser::Parser() {

View file

@ -74,6 +74,7 @@ namespace HTTP {
public:
URL(const std::string & url);
uint32_t getPort() const;
std::string getUrl() const;
std::string host;///< Hostname or IP address of URL
std::string protocol;///<Protocol of URL
std::string port;///<Port of URL