diff options
-rw-r--r-- | src/IO/http.c | 4 | ||||
-rw-r--r-- | src/cookies.c | 21 | ||||
-rw-r--r-- | src/cookies.h | 4 |
3 files changed, 14 insertions, 15 deletions
diff --git a/src/IO/http.c b/src/IO/http.c index dd5cf1b6..41774dc8 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -202,7 +202,7 @@ char *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) (URL_PATH_(url) || URL_QUERY_(url)) ? "" : "/"); } - cookies = a_Cookies_get(url); + cookies = a_Cookies_get_query(url); referer = Http_get_referer(url); if (URL_FLAGS(url) & URL_Post) { dStr_sprintfa( @@ -214,7 +214,6 @@ char *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) "%s" "User-Agent: Dillo/%s\r\n" "Accept-Encoding: gzip\r\n" - "Cookie2: $Version=\"1\"\r\n" "%s" "Content-type: application/x-www-form-urlencoded\r\n" "Content-length: %ld\r\n" @@ -237,7 +236,6 @@ char *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) "%s" "User-Agent: Dillo/%s\r\n" "Accept-Encoding: gzip\r\n" - "Cookie2: $Version=\"1\"\r\n" "Connection: close\r\n" "%s" "\r\n", diff --git a/src/cookies.c b/src/cookies.c index accdd9ad..4acb4c7f 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -168,23 +168,21 @@ void a_Cookies_set(Dlist *cookie_strings, const DilloUrl *set_url) } /* - * Return a string that contains all relevant cookies as headers. + * Return a string containing cookie data for an HTTP query. */ -char *a_Cookies_get(const DilloUrl *request_url) +char *a_Cookies_get_query(const DilloUrl *request_url) { - char *cmd, *dpip_tag, *cookie, numstr[16]; + char *cmd, *dpip_tag, *query, numstr[16]; const char *path; CookieControlAction action; - cookie = dStrdup(""); - if (disabled) - return cookie; + return dStrdup(""); action = Cookies_control_check(request_url); if (action == COOKIE_DENY) { DEBUG_MSG(5, "Cookies: denied GET for %s\n", URL_HOST_(request_url)); - return cookie; + return dStrdup(""); } path = URL_PATH_(request_url); @@ -197,12 +195,15 @@ char *a_Cookies_get(const DilloUrl *request_url) dpip_tag = a_Dpi_send_blocking_cmd("cookies", cmd); dFree(cmd); + query = dStrdup("Cookie2: $Version=\"1\"\r\n"); + if (dpip_tag != NULL) { - dFree(cookie); - cookie = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cookie"); + char *cookie = a_Dpip_get_attr(dpip_tag, strlen(dpip_tag), "cookie"); dFree(dpip_tag); + query = dStrconcat(query, cookie, NULL); + dFree(cookie); } - return cookie; + return query; } /* ------------------------------------------------------------- diff --git a/src/cookies.h b/src/cookies.h index c792d633..6f9f77e0 100644 --- a/src/cookies.h +++ b/src/cookies.h @@ -7,11 +7,11 @@ extern "C" { #ifdef DISABLE_COOKIES -# define a_Cookies_get(url) dStrdup("") +# define a_Cookies_get_query(url) dStrdup("") # define a_Cookies_init() ; # define a_Cookies_freeall() ; #else - char *a_Cookies_get(const DilloUrl *request_url); + char *a_Cookies_get_query(const DilloUrl *request_url); void a_Cookies_set(Dlist *cookie_string, const DilloUrl *set_url); void a_Cookies_init( void ); void a_Cookies_freeall( void ); |