lib1978.c (3851B)
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 "first.h" 25 26 #include "memdebug.h" 27 28 static CURLcode test_lib1978(char *URL) 29 { 30 CURL *curl; 31 CURLcode res = TEST_ERR_MAJOR_BAD; 32 struct curl_slist *connect_to = NULL; 33 struct curl_slist *list = NULL; 34 35 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { 36 curl_mfprintf(stderr, "curl_global_init() failed\n"); 37 return TEST_ERR_MAJOR_BAD; 38 } 39 40 curl = curl_easy_init(); 41 if(!curl) { 42 curl_mfprintf(stderr, "curl_easy_init() failed\n"); 43 curl_global_cleanup(); 44 return TEST_ERR_MAJOR_BAD; 45 } 46 47 test_setopt(curl, CURLOPT_UPLOAD, 1L); 48 test_setopt(curl, CURLOPT_INFILESIZE, 0L); 49 test_setopt(curl, CURLOPT_VERBOSE, 1L); 50 test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3"); 51 test_setopt(curl, CURLOPT_USERPWD, "xxx"); 52 test_setopt(curl, CURLOPT_HEADER, 0L); 53 test_setopt(curl, CURLOPT_URL, URL); 54 55 /* We want to test a couple assumptions here. 56 1. the merging works with non-adjacent headers 57 2. the merging works across multiple duplicate headers 58 3. the merging works if a duplicate header has no colon 59 4. the merging works if the headers are cased differently 60 5. the merging works across multiple duplicate headers 61 6. the merging works across multiple duplicate headers with the 62 same value 63 7. merging works for headers all with no values 64 8. merging works for headers some with no values 65 */ 66 67 list = curl_slist_append(list, "x-amz-meta-test: test2"); 68 if(!list) 69 goto test_cleanup; 70 curl_slist_append(list, "some-other-header: value"); 71 curl_slist_append(list, "x-amz-meta-test: test1"); 72 curl_slist_append(list, "duplicate-header: duplicate"); 73 curl_slist_append(list, "header-no-value"); 74 curl_slist_append(list, "x-amz-meta-test: test3"); 75 curl_slist_append(list, "X-amz-meta-test2: test2"); 76 curl_slist_append(list, "x-amz-meta-blah: blah"); 77 curl_slist_append(list, "x-Amz-meta-test2: test1"); 78 curl_slist_append(list, "x-amz-Meta-test2: test3"); 79 curl_slist_append(list, "curr-header-no-colon"); 80 curl_slist_append(list, "curr-header-no-colon: value"); 81 curl_slist_append(list, "next-header-no-colon: value"); 82 curl_slist_append(list, "next-header-no-colon"); 83 curl_slist_append(list, "duplicate-header: duplicate"); 84 curl_slist_append(list, "header-no-value;"); 85 curl_slist_append(list, "header-no-value;"); 86 curl_slist_append(list, "header-some-no-value;"); 87 curl_slist_append(list, "header-some-no-value: value"); 88 89 test_setopt(curl, CURLOPT_HTTPHEADER, list); 90 if(libtest_arg2) { 91 connect_to = curl_slist_append(connect_to, libtest_arg2); 92 } 93 test_setopt(curl, CURLOPT_CONNECT_TO, connect_to); 94 95 res = curl_easy_perform(curl); 96 97 test_cleanup: 98 99 curl_slist_free_all(connect_to); 100 curl_slist_free_all(list); 101 curl_easy_cleanup(curl); 102 curl_global_cleanup(); 103 104 return res; 105 }