work in progress: client component
This commit is contained in:
parent
8fac8579ef
commit
40a94ce350
1 changed files with 10 additions and 4 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue