mirror of
https://github.com/curl/curl.git
synced 2026-07-26 02:07:16 +03:00
Fix behaviour when passing NULL to CURLOPT_POSTFIELDS and CURLOPT_HTTPPOST.
This commit is contained in:
parent
8c16696f47
commit
59c063dfd3
11 changed files with 209 additions and 19 deletions
|
|
@ -27,7 +27,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
|
|||
test172 test204 test205 test173 test174 test175 test176 test177 \
|
||||
test513 test514 test178 test179 test180 test181 test182 test183 \
|
||||
test184 test185 test186 test187 test188 test189 test191 test192 \
|
||||
test193 test194 test195 test196 test197 test198
|
||||
test193 test194 test195 test196 test197 test198 test515 test516
|
||||
|
||||
# The following tests have been removed from the dist since they no longer
|
||||
# work. We need to fix the test suite's FTPS server first, then bring them
|
||||
|
|
|
|||
46
tests/data/test515
Normal file
46
tests/data/test515
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
HTTP/1.1 200 OK swsclose
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
|
||||
OK
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# tool is what to use instead of 'curl'
|
||||
<tool>
|
||||
lib515
|
||||
</tool>
|
||||
|
||||
<name>
|
||||
make a POSTFIELDS set to NULL with POSTFIELDSIZE set to zero
|
||||
</name>
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/515
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
POST /515 HTTP/1.1
|
||||
Host: 127.0.0.1:%HTTPPORT
|
||||
Pragma: no-cache
|
||||
Accept: */*
|
||||
Content-Length: 0
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
45
tests/data/test516
Normal file
45
tests/data/test516
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
HTTP/1.1 200 OK swsclose
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
|
||||
OK
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# tool is what to use instead of 'curl'
|
||||
<tool>
|
||||
lib516
|
||||
</tool>
|
||||
|
||||
<name>
|
||||
make a HTTPPOST set to NULL
|
||||
</name>
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/516
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
POST /516 HTTP/1.1
|
||||
Host: 127.0.0.1:%HTTPPORT
|
||||
Pragma: no-cache
|
||||
Accept: */*
|
||||
Content-Length: 0
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
24
tests/libtest/lib515.c
Normal file
24
tests/libtest/lib515.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
23
tests/libtest/lib516.c
Normal file
23
tests/libtest/lib516.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue