1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
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.haxx.se/docs/copyright.html.
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.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 /* This test case and code is based on the bug recipe Joe Malicki provided for
24 * bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release.
33 static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream)
35 static size_t total=POSTLEN;
36 static char buf[1024];
39 memset(buf, 'A', sizeof(buf));
45 if(size > sizeof(buf))
48 memcpy(ptr, buf, size);
54 #define SIZE_HEADERS 5000
56 static char buf[SIZE_HEADERS + 100];
61 CURLcode res = CURLE_FAILED_INIT;
63 struct curl_slist *headerlist=NULL, *hl;
65 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
66 fprintf(stderr, "curl_global_init() failed\n");
67 return TEST_ERR_MAJOR_BAD;
70 curl = curl_easy_init();
72 fprintf(stderr, "curl_easy_init() failed\n");
73 curl_global_cleanup();
74 return TEST_ERR_MAJOR_BAD;
77 for(i = 0; i < NUM_HEADERS; i++) {
78 int len = snprintf(buf, sizeof(buf), "Header%d: ", i);
79 memset(&buf[len], 'A', SIZE_HEADERS);
80 buf[len + SIZE_HEADERS]=0; /* zero terminate */
81 hl = curl_slist_append(headerlist, buf);
87 hl = curl_slist_append(headerlist, "Expect: ");
92 test_setopt(curl, CURLOPT_URL, URL);
93 test_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
94 test_setopt(curl, CURLOPT_POST, 1L);
95 #ifdef CURL_DOES_CONVERSIONS
96 /* Convert the POST data to ASCII */
97 test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
99 test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
100 test_setopt(curl, CURLOPT_VERBOSE, 1L);
101 test_setopt(curl, CURLOPT_HEADER, 1L);
102 test_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
104 res = curl_easy_perform(curl);
108 curl_easy_cleanup(curl);
110 curl_slist_free_all(headerlist);
112 curl_global_cleanup();