Skip to content

Commit f2b7a2a

Browse files
committed
Added week_day to cookie_date expiration
1 parent 75728b1 commit f2b7a2a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

include/curl_easy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ namespace curl {
10141014

10151015
// Implementation of get_info method.
10161016
template<typename T> curl::curl_easy_info<T> curl_easy::get_info(const CURLINFO info) {
1017-
T *pointer = nullptr;
1017+
T *pointer;
10181018
const CURLcode code = curl_easy_getinfo(this->curl,info,&pointer);
10191019
curl::curl_easy_info<T> inf(code,pointer);
10201020
return inf;

test/cookie.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "curl_form.h"
66
#include "curl_cookie.h"
77
#include "curl_ios.h"
8+
#include "cookie_datetime.h"
89

910
using std::ostringstream;
1011

@@ -15,7 +16,9 @@ using curl::curl_easy_exception;
1516
using curl::curl_cookie;
1617
using curl::curlcpp_cookies;
1718
using curl::curl_ios;
18-
19+
using curl::cookie_date;
20+
using curl::cookie_time;
21+
using curl::cookie_datetime;
1922

2023
/**
2124
* This example shows to how to set and get cookies in a
@@ -32,13 +35,17 @@ int main() {
3235
curl_easy easy(ios);
3336
easy.add<CURLOPT_URL>("http://example.com");
3437

35-
// Let's create a cooie
38+
// Let's create a cookie which expires at Mon, 27-03-2016 20:30:30 GMT
3639
cookie ck;
40+
cookie_date date(curl::weekdays::MONDAY,27,curl::months::MARCH,2016);
41+
cookie_time time(20,30,30);
42+
cookie_datetime datetime(time,date);
43+
3744
ck.set_name("nomecookie");
3845
ck.set_value("valorecookie");
3946
ck.set_path("/");
4047
ck.set_domain(".example.com");
41-
std::cout<<ck.get_formatted()<<std::endl;
48+
ck.set_datetime(datetime);
4249

4350
// Create a cookie object and add the previously created cookie.
4451
curl_cookie c_obj(easy);
@@ -51,11 +58,10 @@ int main() {
5158
// Retrieve all the cookies for the example.com
5259
cookies = c_obj.get();
5360
// Delete all the memory helded cookies.
54-
easy.add<CURLOPT_COOKIEFILE>("ALL");
61+
c_obj.erase();
5562
} catch (curl_easy_exception error) {
5663
error.print_traceback();
5764
}
58-
std::cout<<cookies.size()<<std::endl;
5965
// Print them all!
6066
for (auto cook : cookies) {
6167
std::cout<<cook<<std::endl;

0 commit comments

Comments
 (0)