You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Sat, Mar 5, 2022, 4:32 AM Agathon ***@***.***> wrote:
Now you can do curl '$url', but it's faster to have a function for
GETting built into ABS :
`import "github.com/valyala/fasthttp"
........
// httpGET(string:"https://www.example.com")
func httpGETFn(tok token.Token, env *object.Environment, args
...object.Object) object.Object {
err := validateArgs(tok, "httpGET", args, 1,
[][]string{{object.STRING_OBJ}})
if err != nil { return err }
url := args[0].(*object.String)
readTimeout, _ := time.ParseDuration("1000ms")
writeTimeout, _ := time.ParseDuration("1000ms")
maxIdleConnDuration, _ := time.ParseDuration("1h")
var client *fasthttp.Client
client = &fasthttp.Client{
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
MaxIdleConnDuration: maxIdleConnDuration,
NoDefaultUserAgentHeader: true, // Don't send: User-Agent: fasthttp
DisableHeaderNamesNormalizing: true, // If you set the case on your headers correctly you can enable this
DisablePathNormalizing: true,
// increase DNS cache time to an hour instead of default minute
Dial: (&fasthttp.TCPDialer{ Concurrency: 4096, DNSCacheDuration: time.Hour, }).Dial,
}
req := fasthttp.AcquireRequest()
req.SetRequestURI(url.Value)
req.Header.SetMethod(fasthttp.MethodGet)
resp := fasthttp.AcquireResponse()
err1 := client.Do(req, resp)
if err1 != nil { return &object.String{Token: tok, Value: err1.Error() } }
fasthttp.ReleaseRequest(req)
defer fasthttp.ReleaseResponse(resp)
return &object.String{Token: tok, Value: string(resp.Body())}
}
`
—
Reply to this email directly, view it on GitHub
<#469>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACQFZCXW3A75XJB6BCFMKTU6KTS3ANCNFSM5P64WECA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
Now you can do
curl '$url'
, but it's faster to have a function for GETting built into ABS :The text was updated successfully, but these errors were encountered: