MCPcopy Create free account
hub / github.com/dhn/spk / PostHTTPRequest

Function PostHTTPRequest

utils/requests.go:42–64  ·  view source on GitHub ↗

POST HTTP wrapper

(url string, data []byte)

Source from the content-addressed store, hash-verified

40
41// POST HTTP wrapper
42func 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}

Callers 1

getARINDataFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected