From 59c063dfd38972e06a7f3a0b8f94860a67acdc96 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 11 Nov 2004 23:11:04 +0000 Subject: Fix behaviour when passing NULL to CURLOPT_POSTFIELDS and CURLOPT_HTTPPOST. --- tests/libtest/Makefile.am | 10 +++++++++- tests/libtest/lib515.c | 24 ++++++++++++++++++++++++ tests/libtest/lib516.c | 23 +++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib515.c create mode 100644 tests/libtest/lib516.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 688c7a4b2..06fbe5519 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,7 +39,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 lib512 lib513 lib514 + lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -100,3 +100,11 @@ lib513_DEPENDENCIES = $(LIBDIR)/libcurl.la lib514_SOURCES = lib514.c $(SUPPORTFILES) lib514_LDADD = $(LIBDIR)/libcurl.la lib514_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib515_SOURCES = lib515.c $(SUPPORTFILES) +lib515_LDADD = $(LIBDIR)/libcurl.la +lib515_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib516_SOURCES = lib516.c $(SUPPORTFILES) +lib516_LDADD = $(LIBDIR)/libcurl.la +lib516_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c new file mode 100644 index 000000000..ce075110d --- /dev/null +++ b/tests/libtest/lib515.c @@ -0,0 +1,24 @@ +#include "test.h" + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Now, we should be making a zero byte POST request */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return (int)res; +} diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c new file mode 100644 index 000000000..6e71fb4bb --- /dev/null +++ b/tests/libtest/lib516.c @@ -0,0 +1,23 @@ +#include "test.h" + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Now, we should be making a zero byte POST request */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return (int)res; +} -- cgit v1.2.3