POST HTTP wrapper
(url string, data []byte)
| 40 | |
| 41 | // POST HTTP wrapper |
| 42 | func PostHTTPRequest(url string, data []byte) *fasthttp.Response { |
| 43 | req := fasthttp.AcquireRequest() |
| 44 | req.SetRequestURI(url) |
| 45 | req.SetBody(data) |
| 46 | |
| 47 | req.Header.SetMethod("POST") |
| 48 | req.Header.Add("User-Agent", uarand.GetRandom()) |
| 49 | req.Header.Add("Content-Type", "application/x-www-form-urlencoded") |
| 50 | |
| 51 | resp := fasthttp.AcquireResponse() |
| 52 | client := &fasthttp.Client{ |
| 53 | Dial: func(addr string) (net.Conn, error) { |
| 54 | return fasthttp.DialTimeout(addr, time.Second*10) |
| 55 | }, |
| 56 | } |
| 57 | |
| 58 | err := client.Do(req, resp) |
| 59 | if err != nil { |
| 60 | gologger.Error().Msgf(err.Error()) |
| 61 | } |
| 62 | |
| 63 | return resp |
| 64 | } |