diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-10-10 13:00:15 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-10-11 21:52:13 +0200 |
commit | ee72a11ca9af081db77ea9dfdf256186a3573ca5 (patch) | |
tree | 41d5a4228dc9219e45d9b5104727314c9e0d24f8 /Userland | |
parent | 53b7edd5b92bd74924a47b84f51d55e38e9164d6 (diff) | |
download | serenity-ee72a11ca9af081db77ea9dfdf256186a3573ca5.zip |
pro: Add argument `--method/-m` for controlling the HTTP method
This lets you send requests like DELETE.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/pro.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp index ae74ebe67c..d761a5c27d 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -154,6 +154,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) char const* data = nullptr; StringView proxy_spec; String method = "GET"; + StringView method_override; HashMap<String, String, CaseInsensitiveStringTraits> request_headers; Core::ArgsParser args_parser; @@ -162,6 +163,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) "and thus supports at least http, https, and gemini."); args_parser.add_option(save_at_provided_name, "Write to a file named as the remote file", nullptr, 'O'); args_parser.add_option(data, "(HTTP only) Send the provided data via an HTTP POST request", "data", 'd', "data"); + args_parser.add_option(method_override, "(HTTP only) HTTP method to use for the request (eg, GET, POST, etc)", "method", 'm', "method"); args_parser.add_option(should_follow_url, "(HTTP only) Follow the Location header if a 3xx status is encountered", "follow", 'l'); args_parser.add_option(Core::ArgsParser::Option { .argument_mode = Core::ArgsParser::OptionArgumentMode::Required, @@ -181,7 +183,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(url_str, "URL to download from", "url"); args_parser.parse(arguments); - if (data) { + if (!method_override.is_empty()) { + method = method_override; + } else if (data) { method = "POST"; // FIXME: Content-Type? } |