b0: remove hardcoded timeouts in blossom client.
see nostr:nevent1qvzqqqqqqypzqmjxss3dld622uu8q25gywum9qtg4w4cv4064jmg20xsac2aam5nqyd8wumn8ghj7urewfsk66ty9enxjct5dfskvtnrdakj7qpqrfcfcq52gfv6znm8hkdpa3rlxad72zl6ah4haaneqzdxwmnamg3sk2sztg
This commit is contained in:
@@ -30,16 +30,13 @@ func NewClient(mediaserver string, signer nostr.Signer) *Client {
|
|||||||
|
|
||||||
// createHTTPClient creates a properly configured HTTP client
|
// createHTTPClient creates a properly configured HTTP client
|
||||||
func createHTTPClient() *fasthttp.Client {
|
func createHTTPClient() *fasthttp.Client {
|
||||||
readTimeout, _ := time.ParseDuration("10s")
|
|
||||||
writeTimeout, _ := time.ParseDuration("10s")
|
|
||||||
maxIdleConnDuration, _ := time.ParseDuration("1h")
|
|
||||||
return &fasthttp.Client{
|
return &fasthttp.Client{
|
||||||
ReadTimeout: readTimeout,
|
MaxIdleConnDuration: time.Hour,
|
||||||
WriteTimeout: writeTimeout,
|
DisableHeaderNamesNormalizing: true, // because our headers are properly constructed
|
||||||
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,
|
DisablePathNormalizing: true,
|
||||||
|
|
||||||
|
Name: "nl-b", // user-agent
|
||||||
|
|
||||||
// increase DNS cache time to an hour instead of default minute
|
// increase DNS cache time to an hour instead of default minute
|
||||||
Dial: (&fasthttp.TCPDialer{
|
Dial: (&fasthttp.TCPDialer{
|
||||||
Concurrency: 4096,
|
Concurrency: 4096,
|
||||||
|
|||||||
@@ -46,7 +46,13 @@ func (c *Client) httpCall(
|
|||||||
req.SetBodyStream(body, int(contentSize))
|
req.SetBodyStream(body, int(contentSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.httpClient.Do(req, resp)
|
var err error
|
||||||
|
if deadline, ok := ctx.Deadline(); ok {
|
||||||
|
err = c.httpClient.DoDeadline(req, resp, deadline)
|
||||||
|
} else {
|
||||||
|
err = c.httpClient.Do(req, resp)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to call %s: %w\n", url, err)
|
return fmt.Errorf("failed to call %s: %w\n", url, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user