From 2c45fc5619cbc33f2441cb07fedb3ca18604ee89 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 21 Dec 2023 16:43:02 +0200 Subject: [PATCH] Use slow transport for validation data fetching --- imessage/direct/nacserv/client.go | 2 +- imessage/direct/util/httputil/client.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/imessage/direct/nacserv/client.go b/imessage/direct/nacserv/client.go index 6ba7a6a..e8a7dcf 100644 --- a/imessage/direct/nacserv/client.go +++ b/imessage/direct/nacserv/client.go @@ -87,7 +87,7 @@ func (c *Client) fetch(ctx context.Context, url string, body []byte, dataType st log.Info().Str("url", req.URL.String()).Str("data_type", dataType).Msg("Fetching nacserv data") - resp, data, err := httputil.Do(httputil.Normal, req) + resp, data, err := httputil.Do(httputil.Slow, req) if err != nil { return nil, fmt.Errorf("failed to send request: %w", err) } else if resp.StatusCode != http.StatusOK { diff --git a/imessage/direct/util/httputil/client.go b/imessage/direct/util/httputil/client.go index 5584268..05f952e 100644 --- a/imessage/direct/util/httputil/client.go +++ b/imessage/direct/util/httputil/client.go @@ -34,7 +34,12 @@ var normalTransport = &http.Transport{ TLSHandshakeTimeout: 10 * time.Second, ResponseHeaderTimeout: 5 * time.Second, } -var slowTransport = &http.Transport{} +var slowTransport = &http.Transport{ + DialContext: (&net.Dialer{Timeout: 20 * time.Second}).DialContext, + ForceAttemptHTTP2: true, + TLSHandshakeTimeout: 20 * time.Second, + ResponseHeaderTimeout: 60 * time.Second, +} var appleTLSTransport = &http.Transport{ TLSClientConfig: &tls.Config{ RootCAs: appletls.CertPool,