aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/curl.cxx13
-rw-r--r--tests/curl/driver.cxx4
-rw-r--r--tests/curl/testscript5
3 files changed, 18 insertions, 4 deletions
diff --git a/libbutl/curl.cxx b/libbutl/curl.cxx
index 7efd28d..5649965 100644
--- a/libbutl/curl.cxx
+++ b/libbutl/curl.cxx
@@ -21,9 +21,20 @@ namespace butl
{
case ftp_put:
throw invalid_argument ("no input specified for PUT method");
+ case http_post:
+ {
+ // Post the empty data.
+ //
+ // Note that while it's tempting to specify the --request POST option
+ // instead, that can potentially overwrite the request methods for the
+ // HTTP 30X response code redirects.
+ //
+ d.options.push_back ("--data-raw");
+ d.options.push_back ("");
+ }
+ // Fall through.
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 bd12c29..856fde3 100644
--- a/tests/curl/driver.cxx
+++ b/tests/curl/driver.cxx
@@ -118,10 +118,10 @@ http ()
assert (c.wait ());
}
- // POST from /dev/null.
+ // POST empty data.
//
{
- curl c (p, nullfd, 1, 2, curl::post, u + "/bogus");
+ curl c (p, nullfd, 1, 2, curl::post, u + "/bogus", "--verbose");
assert (!c.wait ());
}
}
diff --git a/tests/curl/testscript b/tests/curl/testscript
index 5818d1a..d2056cd 100644
--- a/tests/curl/testscript
+++ b/tests/curl/testscript
@@ -55,7 +55,10 @@ sudo /usr/sbin/in.tftpd \
curl -sS --location --data-binary @- https://build2.org/bogus
- curl -sS --fail --location https://build2.org/bogus
+ curl -sS --fail --location --data-raw "" --verbose https://build2.org/bogus
+ %.*
+ %> POST /bogus HTTP.+%
+ %.*
%curl: \(22\) The requested URL returned error: 404( Not Found)?%
EOE
}