More temporary string cleanup.
This commit is contained in:
@ -1318,15 +1318,14 @@ static void Cookies_add_matching_cookies(const char *domain,
|
||||
/*
|
||||
* Return a string that contains all relevant cookies as headers.
|
||||
*/
|
||||
static char *Cookies_get(char *url_host, char *url_path,
|
||||
static std::string Cookies_get(char *url_host, char *url_path,
|
||||
char *url_scheme)
|
||||
{
|
||||
char *domain_str, *str;
|
||||
char *domain_str;
|
||||
CookieData_t *cookie;
|
||||
Dlist *matching_cookies;
|
||||
bool_t is_tls, is_ip_addr, host_only_val;
|
||||
|
||||
Dstr *cookie_dstring;
|
||||
int i;
|
||||
|
||||
if (disabled)
|
||||
@ -1380,27 +1379,27 @@ static char *Cookies_get(char *url_host, char *url_path,
|
||||
}
|
||||
|
||||
/* Found the cookies, now make the string */
|
||||
cookie_dstring = dStr_new("");
|
||||
std::string cookie_dstring;
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
if (dList_length(matching_cookies) > 0) {
|
||||
|
||||
dStr_sprintfa(cookie_dstring, "Cookie: ");
|
||||
cookie_dstring+= "Cookie: ";
|
||||
|
||||
for (i = 0; (cookie = reinterpret_cast< CookieData_t * >( dList_nth_data(matching_cookies, i) )); ++i) {
|
||||
dStr_sprintfa(cookie_dstring, "%s=%s", cookie->name, cookie->value);
|
||||
dStr_append(cookie_dstring,
|
||||
dList_length(matching_cookies) > i + 1 ? "; " : "\r\n");
|
||||
cookie_dstring+= cookie->name + "="s + cookie->value;
|
||||
cookie_dstring+=
|
||||
dList_length(matching_cookies) > i + 1 ? "; " : "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
dList_free(matching_cookies);
|
||||
str = cookie_dstring->str;
|
||||
dStr_free(cookie_dstring, FALSE);
|
||||
|
||||
if (*str) {
|
||||
MSG("%s GETTING: %s", url_host, str);
|
||||
if (not cookie_dstring.empty()) {
|
||||
MSG("%s GETTING: %s", url_host, cookie_dstring.c_str());
|
||||
cookies_use_counter++;
|
||||
}
|
||||
return str;
|
||||
return cookie_dstring;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
@ -1544,7 +1543,7 @@ static CookieControlAction Cookies_control_check_domain(const char *domain)
|
||||
*/
|
||||
static int srv_parse_tok(Dsh *sh, ClientInfo *client, char *Buf)
|
||||
{
|
||||
char *cmd, *cookie, *host, *path;
|
||||
char *cmd, *host, *path;
|
||||
int ret = 1;
|
||||
size_t BufSize = strlen(Buf);
|
||||
|
||||
@ -1567,7 +1566,7 @@ static int srv_parse_tok(Dsh *sh, ClientInfo *client, char *Buf)
|
||||
int st;
|
||||
char *date;
|
||||
|
||||
cookie = a_Dpip_get_attr_l(Buf, BufSize, "cookie");
|
||||
char *cookie = a_Dpip_get_attr_l(Buf, BufSize, "cookie");
|
||||
host = a_Dpip_get_attr_l(Buf, BufSize, "host");
|
||||
path = a_Dpip_get_attr_l(Buf, BufSize, "path");
|
||||
date = a_Dpip_get_attr_l(Buf, BufSize, "date");
|
||||
@ -1591,13 +1590,13 @@ static int srv_parse_tok(Dsh *sh, ClientInfo *client, char *Buf)
|
||||
host = a_Dpip_get_attr_l(Buf, BufSize, "host");
|
||||
path = a_Dpip_get_attr_l(Buf, BufSize, "path");
|
||||
|
||||
cookie = Cookies_get(host, path, scheme);
|
||||
std::string cookie = Cookies_get(host, path, scheme);
|
||||
dFree(scheme);
|
||||
dFree(path);
|
||||
dFree(host);
|
||||
|
||||
dFree(cmd);
|
||||
cmd = a_Dpip_build_cmd("cmd=%s cookie=%s", "get_cookie_answer", cookie);
|
||||
cmd = a_Dpip_build_cmd("cmd=%s cookie=%s", "get_cookie_answer", cookie.c_str());
|
||||
|
||||
if (a_Dpip_dsh_write_str(sh, 1, cmd)) {
|
||||
ret = 1;
|
||||
@ -1605,7 +1604,6 @@ static int srv_parse_tok(Dsh *sh, ClientInfo *client, char *Buf)
|
||||
_MSG("a_Dpip_dsh_write_str: SUCCESS cmd={%s}\n", cmd);
|
||||
ret = 2;
|
||||
}
|
||||
dFree(cookie);
|
||||
}
|
||||
dFree(cmd);
|
||||
|
||||
|
Reference in New Issue
Block a user