1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2011, 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 http://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 if((curl = curl_easy_init()) == NULL) {
71 fprintf(stderr, "curl_easy_init() failed\n");
72 curl_global_cleanup();
73 return TEST_ERR_MAJOR_BAD;
76 for (i = 0; i < NUM_HEADERS; i++) {
77 int len = sprintf(buf, "Header%d: ", i);
78 memset(&buf[len], 'A', SIZE_HEADERS);
79 buf[len + SIZE_HEADERS]=0; /* zero terminate */
80 hl = curl_slist_append(headerlist, buf);
86 hl = curl_slist_append(headerlist, "Expect: ");
91 test_setopt(curl, CURLOPT_URL, URL);
92 test_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
93 test_setopt(curl, CURLOPT_POST, 1L);
94 #ifdef CURL_DOES_CONVERSIONS
95 /* Convert the POST data to ASCII */
96 test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
98 test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
99 test_setopt(curl, CURLOPT_VERBOSE, 1L);
100 test_setopt(curl, CURLOPT_HEADER, 1L);
101 test_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
103 res = curl_easy_perform(curl);
107 curl_easy_cleanup(curl);
109 curl_slist_free_all(headerlist);
111 curl_global_cleanup();