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(