| 93 | } |
| 94 | |
| 95 | func startPush(b, e int) { |
| 96 | l := make([]int64, 0, e-b) |
| 97 | for i := b; i < e; i++ { |
| 98 | l = append(l, int64(i)) |
| 99 | } |
| 100 | msg := &pushsBodyMsg{Msg: json.RawMessage(testContent), UserIds: l} |
| 101 | body, err := json.Marshal(msg) |
| 102 | if err != nil { |
| 103 | panic(err) |
| 104 | } |
| 105 | for { |
| 106 | resp, err := httpPost(fmt.Sprintf("http://%s/goim/push/mids=%d", os.Args[3], b), "application/x-www-form-urlencoded", bytes.NewBuffer(body)) |
| 107 | if err != nil { |
| 108 | lg.Printf("post error (%v)", err) |
| 109 | continue |
| 110 | } |
| 111 | |
| 112 | body, err := ioutil.ReadAll(resp.Body) |
| 113 | if err != nil { |
| 114 | lg.Printf("post error (%v)", err) |
| 115 | return |
| 116 | } |
| 117 | resp.Body.Close() |
| 118 | |
| 119 | lg.Printf("response %s", string(body)) |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | func httpPost(url string, contentType string, body io.Reader) (*http.Response, error) { |
| 124 | req, err := http.NewRequest("POST", url, body) |