From 5ef773867ce0eb0a79265169f2ae34ff1819d5db Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 26 Aug 2025 14:41:53 +0530 Subject: [PATCH] config: fix setting postrequest config PR #161 introduced `postrequest` config but there was no way to update that config other than updating the config file. This PR fixes the behaviour. Also adds a log to highlight what HTTP method is used. Signed-off-by: Abhishek Kumar --- cmd/network.go | 4 +++- cmd/set.go | 1 + config/config.go | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/network.go b/cmd/network.go index 7b5807a9..286abb5d 100644 --- a/cmd/network.go +++ b/cmd/network.go @@ -411,9 +411,11 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str func executeRequest(r *Request, requestURL string, params url.Values) (*http.Response, error) { config.SetupContext(r.Config) if params.Has("password") || params.Has("userdata") || r.Config.Core.PostRequest { - requestURL = fmt.Sprintf("%s", r.Config.ActiveProfile.URL) + requestURL = r.Config.ActiveProfile.URL + config.Debug("Using HTTP POST for the request: ", requestURL) return r.Client().PostForm(requestURL, params) } + config.Debug("Using HTTP GET for the request: ", requestURL) req, _ := http.NewRequestWithContext(*r.Config.Context, "GET", requestURL, nil) return r.Client().Do(req) } diff --git a/cmd/set.go b/cmd/set.go index ee7c7374..c8bba8af 100644 --- a/cmd/set.go +++ b/cmd/set.go @@ -45,6 +45,7 @@ func init() { "verifycert": {"true", "false"}, "debug": {"true", "false"}, "autocomplete": {"true", "false"}, + "postrequest": {"true", "false"}, }, Handle: func(r *Request) error { if len(r.Args) < 1 { diff --git a/config/config.go b/config/config.go index bcd3f6fa..cf32b69a 100644 --- a/config/config.go +++ b/config/config.go @@ -76,7 +76,7 @@ type Core struct { VerifyCert bool `ini:"verifycert"` ProfileName string `ini:"profile"` AutoComplete bool `ini:"autocomplete"` - PostRequest bool `ini:postrequest` + PostRequest bool `ini:"postrequest"` } // Config describes CLI config file and default options @@ -401,6 +401,8 @@ func (c *Config) UpdateConfig(key string, value string, update bool) { } case "autocomplete": c.Core.AutoComplete = value == "true" + case "postrequest": + c.Core.PostRequest = value == "true" default: fmt.Println("Invalid option provided:", key) return