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())
|
pdata = strings.NewReader(pl.String())
|
||||||
method = "POST"
|
method = "POST"
|
||||||
}
|
}
|
||||||
req, _ := http.NewRequest(method, url, pdata)
|
resp, err := SendRequest(method, url, pdata)
|
||||||
client := http.DefaultClient
|
|
||||||
client.Jar = GlobalCookieJar
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.ErrorA(act, err).Msg("client.Send")
|
logging.ErrorA(act, err).Msg("client.Send")
|
||||||
return true
|
return true
|
||||||
|
@ -43,9 +40,18 @@ func Send(act lib.Action) bool {
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
body, _ := ioutil.ReadAll(resp.Body)
|
||||||
bodyStr := string(body)
|
bodyStr := string(body)
|
||||||
logging.InfoA(act).Str("data", bodyStr).Msg("client.Send")
|
logging.InfoA(act).Str("data", bodyStr).Msg("client.Send")
|
||||||
|
// core.Forward(newMsg)
|
||||||
return true
|
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
|
// CookieJar initialization
|
||||||
func init() {
|
func init() {
|
||||||
GlobalCookieJar, _ = cookiejar.New(
|
GlobalCookieJar, _ = cookiejar.New(
|
||||||
|
|
Loading…
Add table
Reference in a new issue