aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-02-23 17:59:10 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-02-26 11:52:12 +0300
commit14049ee7c5880b9e33a3e295d19ed6b36edab567 (patch)
tree05ba211496e3ae56033fe569ab855529aa6f8008
parent4a3ec1c7e77e3da09d39ab57048bc6b1a39fb003 (diff)
Allow nullfd input for HTTP POST method in curl class constructor
-rw-r--r--libbutl/curl.cxx3
-rw-r--r--tests/curl/driver.cxx7
-rw-r--r--tests/curl/testscript3
3 files changed, 11 insertions, 2 deletions
diff --git a/libbutl/curl.cxx b/libbutl/curl.cxx
index 92baa4c..0577391 100644
--- a/libbutl/curl.cxx
+++ b/libbutl/curl.cxx
@@ -21,10 +21,9 @@ namespace butl
{
case ftp_put:
throw invalid_argument ("no input specified for PUT method");
- case http_post:
- throw invalid_argument ("no input specified for POST method");
case ftp_get:
case http_get:
+ case http_post:
{
d.pipe.in = fdopen_null (); // /dev/null
return pipe (d.pipe);
diff --git a/tests/curl/driver.cxx b/tests/curl/driver.cxx
index 72faf52..4cf1815 100644
--- a/tests/curl/driver.cxx
+++ b/tests/curl/driver.cxx
@@ -104,6 +104,13 @@ http ()
c.out.close ();
assert (!c.wait ());
}
+
+ // POST from /dev/null.
+ //
+ {
+ curl c (p, nullfd, 1, 2, curl::post, u + "/bogus");
+ assert (!c.wait ());
+ }
}
int
diff --git a/tests/curl/testscript b/tests/curl/testscript
index 453c09a..d26a39c 100644
--- a/tests/curl/testscript
+++ b/tests/curl/testscript
@@ -52,5 +52,8 @@ sudo /usr/sbin/in.tftpd \
curl -s -S --fail --location --data-binary @- https://build2.org/bogus
%curl: \(22\) The requested URL returned error: 404( Not Found)?%
+
+ curl -s -S --fail --location https://build2.org/bogus
+ %curl: \(22\) The requested URL returned error: 404( Not Found)?%
EOE
}