summaryrefslogtreecommitdiff
path: root/tests/libtest/lib553.c
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2008-07-11 18:23:06 +0000
committerDan Fandrich <dan@coneharvesters.com>2008-07-11 18:23:06 +0000
commit336992cc54583b4ca949401d93ca3194e226d21e (patch)
treea9ce7a3e39b9158ef72277a9836642e181d793eb /tests/libtest/lib553.c
parent13afcbd1ebcd9069d8782769aa9c64ab6cd0329f (diff)
downloadcurl-336992cc54583b4ca949401d93ca3194e226d21e.tar.gz
Fixed test 553 to pass the torture test.
Diffstat (limited to 'tests/libtest/lib553.c')
-rw-r--r--tests/libtest/lib553.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c
index 7af25e5bb..0603b3fd5 100644
--- a/tests/libtest/lib553.c
+++ b/tests/libtest/lib553.c
@@ -39,36 +39,47 @@ static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream)
#define SIZE_HEADERS 5000
static char buf[SIZE_HEADERS + 100];
+
int test(char *URL)
{
CURL *curl;
CURLcode res;
int i;
- struct curl_slist *headerlist=NULL;
+ struct curl_slist *headerlist=NULL, *hl;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
- for (i = 0; i < NUM_HEADERS; i++) {
- int len;
- len = sprintf(buf, "Header%d: ", i);
- memset(&buf[len], 'A', SIZE_HEADERS);
- buf[len + SIZE_HEADERS]=0; /* zero terminate */
- headerlist = curl_slist_append(headerlist, buf);
+ if(curl) {
+ for (i = 0; i < NUM_HEADERS; i++) {
+ int len = sprintf(buf, "Header%d: ", i);
+ memset(&buf[len], 'A', SIZE_HEADERS);
+ buf[len + SIZE_HEADERS]=0; /* zero terminate */
+ hl = curl_slist_append(headerlist, buf);
+ if (!hl)
+ goto errout;
+ headerlist = hl;
+ }
+ hl = curl_slist_append(headerlist, "Expect: ");
+ if (!hl)
+ goto errout;
+ headerlist = hl;
+
+ curl_easy_setopt(curl, CURLOPT_URL, URL);
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
+ curl_easy_setopt(curl, CURLOPT_POST, 1L);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
+ res = curl_easy_perform(curl);
+
+errout:
+ curl_easy_cleanup(curl);
+
+ curl_slist_free_all(headerlist);
}
- headerlist = curl_slist_append(headerlist, "Expect: ");
-
- curl_easy_setopt(curl, CURLOPT_URL, URL);
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
- curl_easy_setopt(curl, CURLOPT_POST, 1L);
- curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
- curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
- res = curl_easy_perform(curl);
- curl_easy_cleanup(curl);
-
- curl_slist_free_all(headerlist);
+ curl_global_cleanup();
return (int)res;
}