Loading lib/cookie.c +9 −15 Changes for lib/cookie.c: 9 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -1456,22 +1456,9 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) unsigned int j; struct Cookie **array; if((NULL == c) || (0 == c->numcookies)) /* If there are no known cookies, we don't write or even create any destination file */ return 0; /* at first, remove expired cookies */ remove_expired(c); /* make sure we still have cookies after expiration */ if(0 == c->numcookies) return 0; array = malloc(sizeof(struct Cookie *) * c->numcookies); if(!array) return 1; if(!strcmp("-", dumphere)) { /* use stdout */ out = stdout; Loading @@ -1480,7 +1467,6 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) else { out = fopen(dumphere, FOPEN_WRITETEXT); if(!out) { free(array); return 1; /* failure */ } } Loading @@ -1490,6 +1476,14 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) "# This file was generated by libcurl! Edit at your own risk.\n\n", out); if(c->numcookies) { array = malloc(sizeof(struct Cookie *) * c->numcookies); if(!array) { if(!use_stdout) fclose(out); return 1; } j = 0; for(i = 0; i < COOKIE_HASH_SIZE; i++) { for(co = c->cookies[i]; co; co = co->next) { Loading @@ -1515,7 +1509,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) } free(array); } if(!use_stdout) fclose(out); Loading tests/data/Makefile.inc +1 −1 Changes for tests/data/Makefile.inc: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ test289 test290 test291 test292 test293 test294 test295 test296 test297 \ test298 test299 test300 test301 test302 test303 test304 test305 test306 \ test307 test308 test309 test310 test311 test312 test313 test314 test315 \ test316 test317 test318 test319 test320 test321 test322 test323 test324 \ test325 test326 \ test325 test326 test327 \ \ test340 \ \ Loading tests/data/test1160 +5 −1 Changes for tests/data/test1160: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -43,7 +43,11 @@ Host: %HOSTIP:%HTTPPORT Accept: */* </protocol> <file name="log/cookies1160.txt"> <file name="log/cookies1160.txt" mode="text"> # Netscape HTTP Cookie File # https://curl.haxx.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. </file> </verify> </testcase> tests/data/test327 +73 Changes for tests/data/test327: 73 added lines, 0 removed lines. Original line number Diff line number Diff line <testcase> <info> <keywords> HTTP HTTP GET cookies header dump </keywords> </info> # This test verifies that the cookie file gets created even if the last cookie # has been removed - particularly important when the file is going to be read # again and thus must not contain old contents. # Server-side <reply> <data> HTTP/1.1 200 OK Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake Content-Type: text/html Funny-head: yesyes swsclose Set-Cookie: foobar=name; expires=Thu, 22 Nov 2028 10:54:11 GMT; </data> <data2> HTTP/1.1 200 OK Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake Content-Type: text/html Funny-head: yesyes swsclose Set-Cookie: foobar=name; expires=Thu, 01 Jan 1970 00:00:00 GMT; </data> </reply> # Client-side <client> <server> http </server> <name> HTTP with cookiejar without cookies left </name> <command> http://%HOSTIP:%HTTPPORT/we/want/327 -b none -c log/cookies327 http://%HOSTIP:%HTTPPORT/we/want/3270002 </command> </client> # Verify data after the test has been "shot" <verify> <strip> ^User-Agent:.* </strip> <protocol> GET /we/want/327 HTTP/1.1 Host: %HOSTIP:%HTTPPORT Accept: */* GET /we/want/3270002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT Accept: */* Cookie: foobar=name </protocol> <file name="log/cookies327" mode="text"> # Netscape HTTP Cookie File # https://curl.haxx.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. </file> </verify> </testcase> Loading
lib/cookie.c +9 −15 Changes for lib/cookie.c: 9 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -1456,22 +1456,9 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) unsigned int j; struct Cookie **array; if((NULL == c) || (0 == c->numcookies)) /* If there are no known cookies, we don't write or even create any destination file */ return 0; /* at first, remove expired cookies */ remove_expired(c); /* make sure we still have cookies after expiration */ if(0 == c->numcookies) return 0; array = malloc(sizeof(struct Cookie *) * c->numcookies); if(!array) return 1; if(!strcmp("-", dumphere)) { /* use stdout */ out = stdout; Loading @@ -1480,7 +1467,6 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) else { out = fopen(dumphere, FOPEN_WRITETEXT); if(!out) { free(array); return 1; /* failure */ } } Loading @@ -1490,6 +1476,14 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) "# This file was generated by libcurl! Edit at your own risk.\n\n", out); if(c->numcookies) { array = malloc(sizeof(struct Cookie *) * c->numcookies); if(!array) { if(!use_stdout) fclose(out); return 1; } j = 0; for(i = 0; i < COOKIE_HASH_SIZE; i++) { for(co = c->cookies[i]; co; co = co->next) { Loading @@ -1515,7 +1509,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) } free(array); } if(!use_stdout) fclose(out); Loading
tests/data/Makefile.inc +1 −1 Changes for tests/data/Makefile.inc: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ test289 test290 test291 test292 test293 test294 test295 test296 test297 \ test298 test299 test300 test301 test302 test303 test304 test305 test306 \ test307 test308 test309 test310 test311 test312 test313 test314 test315 \ test316 test317 test318 test319 test320 test321 test322 test323 test324 \ test325 test326 \ test325 test326 test327 \ \ test340 \ \ Loading
tests/data/test1160 +5 −1 Changes for tests/data/test1160: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -43,7 +43,11 @@ Host: %HOSTIP:%HTTPPORT Accept: */* </protocol> <file name="log/cookies1160.txt"> <file name="log/cookies1160.txt" mode="text"> # Netscape HTTP Cookie File # https://curl.haxx.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. </file> </verify> </testcase>
tests/data/test327 +73 Changes for tests/data/test327: 73 added lines, 0 removed lines. Original line number Diff line number Diff line <testcase> <info> <keywords> HTTP HTTP GET cookies header dump </keywords> </info> # This test verifies that the cookie file gets created even if the last cookie # has been removed - particularly important when the file is going to be read # again and thus must not contain old contents. # Server-side <reply> <data> HTTP/1.1 200 OK Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake Content-Type: text/html Funny-head: yesyes swsclose Set-Cookie: foobar=name; expires=Thu, 22 Nov 2028 10:54:11 GMT; </data> <data2> HTTP/1.1 200 OK Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake Content-Type: text/html Funny-head: yesyes swsclose Set-Cookie: foobar=name; expires=Thu, 01 Jan 1970 00:00:00 GMT; </data> </reply> # Client-side <client> <server> http </server> <name> HTTP with cookiejar without cookies left </name> <command> http://%HOSTIP:%HTTPPORT/we/want/327 -b none -c log/cookies327 http://%HOSTIP:%HTTPPORT/we/want/3270002 </command> </client> # Verify data after the test has been "shot" <verify> <strip> ^User-Agent:.* </strip> <protocol> GET /we/want/327 HTTP/1.1 Host: %HOSTIP:%HTTPPORT Accept: */* GET /we/want/3270002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT Accept: */* Cookie: foobar=name </protocol> <file name="log/cookies327" mode="text"> # Netscape HTTP Cookie File # https://curl.haxx.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. </file> </verify> </testcase>