aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-01-16 22:54:54 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-01-16 22:54:54 +0000
commitc522f349fe5c18f51cf658c35cee2ceb8a38fd46 (patch)
treeb0bebe0acde65a3bf9aa3d2a7a8a01a460a7638d /tests/libtest
parent6893fcaa9b86f04e545f616a7677f2da23982cc8 (diff)
Added test 553. This test case and code is based on the bug recipe Joe Malicki
provided for bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release.
Diffstat (limited to 'tests/libtest')
-rw-r--r--tests/libtest/Makefile.am6
-rw-r--r--tests/libtest/lib553.c74
2 files changed, 78 insertions, 2 deletions
diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am
index 7d9cb64aa..a808a673f 100644
--- a/tests/libtest/Makefile.am
+++ b/tests/libtest/Makefile.am
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -48,7 +48,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \
lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \
lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \
lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \
- lib544 lib545 lib547 lib548 lib549 lib552
+ lib544 lib545 lib547 lib548 lib549 lib552 lib553
# Dependencies (may need to be overriden)
LDADD = $(LIBDIR)/libcurl.la
@@ -147,3 +147,5 @@ lib548_CFLAGS = -DLIB548
lib549_SOURCES = lib549.c $(SUPPORTFILES)
lib552_SOURCES = lib552.c $(SUPPORTFILES)
+
+lib553_SOURCES = lib553.c $(SUPPORTFILES)
diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c
new file mode 100644
index 000000000..f9c118620
--- /dev/null
+++ b/tests/libtest/lib553.c
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * $Id$
+ *
+ * This test case and code is based on the bug recipe Joe Malicki provided for
+ * bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release.
+ */
+
+#include "test.h"
+
+#define POSTLEN 40960
+
+static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream)
+{
+ static size_t total=POSTLEN;
+ static char buf[1024];
+ (void)stream;
+
+ memset(buf, 'A', sizeof(buf));
+
+ size *= nmemb;
+ if (size > total)
+ size = total;
+
+ if(size > sizeof(buf))
+ size = sizeof(buf);
+
+ memcpy(ptr, buf, size);
+ total -= size;
+ return size;
+}
+
+#define NUM_HEADERS 8
+#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;
+
+ 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);
+ }
+ 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, 1);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, POSTLEN);
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+ curl_easy_setopt(curl, CURLOPT_HEADER, 1);
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
+ res = curl_easy_perform(curl);
+ curl_easy_cleanup(curl);
+
+ curl_slist_free_all(headerlist);
+
+ return (int)res;
+}