string DHS::assemble_base_url(const string& hostname, const string& domain_part) const
{
string base_url;
- if ( !domain_part.empty() )
- {
- base_url = "http://members.dhs.org";
- base_url.append("/nic/hosts?hostscmd=edit&hostscmdstage=2&type=4&domain=");
- base_url.append(domain_part);
- base_url.append("&hostname=");
- base_url.append(hostname);
- base_url.append("&updatetype=Online&ip=");
- }
- else
- {
- base_url = "http://members.dhs.org";
- base_url.append("/nic/hosts?hostscmd=edit&hostscmdstage=2&type=4&hostname=");
- base_url.append(hostname);
- base_url.append("&updatetype=Online&ip=");
- }
+
+ base_url = "http://members.dhs.org";
+ base_url.append("/nic/hosts?hostscmd=edit&hostscmdstage=2&type=4&domain=");
+ base_url.append(domain_part);
+ base_url.append("&hostname=");
+ base_url.append(hostname);
+ base_url.append("&updatetype=Online&ip=");
+
return base_url;
}
string url = BaseUrl;
url.append(ip);
- long output = HTTPHelp->http_get(url);
+ // Perform curl operation on given url.
+ long http_status_code = HTTPHelp->http_get(url);
- get_logger()->print_http_status_code(url,output);
+ get_logger()->print_http_status_code(url,http_status_code);
- if ( output == 200 )
- {
+ // Check the status code for protocol errors.
+ if ( http_status_code == 200 )
ret_val = 0;
- }
- else if ( output == -1 )
- {
- ret_val = -1;
- }
- else if ( output == 401 )
- {
+ else if ( http_status_code == 401 )
get_logger()->print_http_not_authorized(url,get_login(),get_password());
- // not authorized
- ret_val = -1;
- }
+ else
+ get_logger()->print_update_failure(url,http_status_code);
return ret_val;
}
string url = BaseUrl;
url.append(ip);
- long output = HTTPHelp->http_get(url);
+ // Perform curl operation on given url
+ long http_status_code = HTTPHelp->http_get(url);
- get_logger()->print_http_status_code(url,output);
+ get_logger()->print_http_status_code(url,http_status_code);
- // HTTP operation completed successful, now we have to parse the data received by curl cause http status code is not significant for dyndns update errors
- if ( output == 200 )
+ // HTTP operation completed successful.
+ // Now we have to parse the data received by curl,
+ // cause http status code is not significant for dyndns update errors
+ if ( http_status_code == 200 )
{
+ // Get the received http data.
string curl_data = HTTPHelp->get_curl_data();
if ( curl_data == good )
get_logger()->print_http_status_code(url,http_status_code);
- // HTTP operation completed successful, now we have to parse the data received by curl cause http status code is not significant for dyns update errors
+ // HTTP operation completed successful.
+ // Now we have to parse the data received by curl,
+ // cause http status code is not significant for dyns update errors
if ( http_status_code == 200 )
{
+ // Get the received http data and parse the status code.
string curl_data = HTTPHelp->get_curl_data();
string status_code = parse_status_code(curl_data);
if ( status_code == "200" )
- {
ret_val = 0;
- }
else if ( status_code == "401" )
- {
- // badauth
get_logger()->print_http_not_authorized(url,get_login(),get_password());
- }
else
- {
- // generic
get_logger()->print_update_failure(url,curl_data);
- }
}
return ret_val;
string url = BaseUrl;
url.append(ip);
- long output = HTTPHelp->http_get(url);
+ long http_status_code = HTTPHelp->http_get(url);
- get_logger()->print_http_status_code(url,output);
+ get_logger()->print_http_status_code(url,http_status_code);
- // HTTP operation completed successful, now we have to parse the data received by curl cause http status code is not significant for dyndns update errors
- if ( output == 200 )
+ // HTTP operation completed successful.
+ // Now we have to parse the data received by curl,
+ // cause http status code is not significant for easydns update errors
+ if ( http_status_code == 200 )
{
+ // Get the received http data.
string curl_data = HTTPHelp->get_curl_data();
if ( curl_data == "NOERROR" )