From 40a94ce350930eab29638b92d0bedf501bf5804c Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 15 Jul 2023 09:02:52 +0200 Subject: [PATCH] work in progress: client component --- client/client.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/client/client.go b/client/client.go index 8bbf028..28a6df3 100644 --- a/client/client.go +++ b/client/client.go @@ -32,10 +32,7 @@ func Send(act lib.Action) bool { pdata = strings.NewReader(pl.String()) method = "POST" } - req, _ := http.NewRequest(method, url, pdata) - client := http.DefaultClient - client.Jar = GlobalCookieJar - resp, err := client.Do(req) + resp, err := SendRequest(method, url, pdata) if err != nil { logging.ErrorA(act, err).Msg("client.Send") return true @@ -43,9 +40,18 @@ func Send(act lib.Action) bool { body, _ := ioutil.ReadAll(resp.Body) bodyStr := string(body) logging.InfoA(act).Str("data", bodyStr).Msg("client.Send") + // core.Forward(newMsg) return true } +func SendRequest(method, url string, pdata io.Reader) (*http.Response, error) { + req, _ := http.NewRequest(method, url, pdata) + client := http.DefaultClient + client.Jar = GlobalCookieJar + resp, err := client.Do(req) + return resp, err +} + // CookieJar initialization func init() { GlobalCookieJar, _ = cookiejar.New(