xref: /curl/tests/libtest/lib3103.c (revision 25cbc2f7)
1 /***************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at https://curl.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  * SPDX-License-Identifier: curl
22  *
23  ***************************************************************************/
24 #include "test.h"
25 
26 #include "memdebug.h"
27 
test(char * URL)28 CURLcode test(char *URL)
29 {
30   CURLcode res = CURLE_OK;
31   CURLSH *share;
32   CURL *curl;
33 
34   curl_global_init(CURL_GLOBAL_ALL);
35 
36   share = curl_share_init();
37   curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
38 
39   curl = curl_easy_init();
40   test_setopt(curl, CURLOPT_SHARE, share);
41 
42   test_setopt(curl, CURLOPT_VERBOSE, 1L);
43   test_setopt(curl, CURLOPT_HEADER, 1L);
44   test_setopt(curl, CURLOPT_PROXY, URL);
45   test_setopt(curl, CURLOPT_URL, "http://localhost/");
46 
47   test_setopt(curl, CURLOPT_COOKIEFILE, "");
48 
49   /* Set a cookie without Max-age or Expires */
50   test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: c1=v1; domain=localhost");
51 
52   res = curl_easy_perform(curl);
53   if(res) {
54     fprintf(stderr, "curl_easy_perform() failed: %s\n",
55             curl_easy_strerror(res));
56   }
57 
58 test_cleanup:
59 
60   /* always cleanup */
61   curl_easy_cleanup(curl);
62   curl_share_cleanup(share);
63   curl_global_cleanup();
64 
65   return res;
66 }
67