Skip to content

Commit

Permalink
Skip proxy when fetching grid images
Browse files Browse the repository at this point in the history
  • Loading branch information
Wikidepia committed Jul 23, 2024
1 parent 2611273 commit ae140cf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion handlers/grid.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"log/slog"
"math"
"net"
"net/http"
"os"
"path/filepath"
Expand All @@ -21,6 +22,18 @@ import (
)

var timeout = 60 * time.Second
var transport = &http.Transport{
Proxy: nil, // Skip any proxy
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
var sflightGrid singleflight.Group

// getHeight returns the height of the rows, imagesWH [w,h]
Expand Down Expand Up @@ -160,7 +173,7 @@ func Grid(w http.ResponseWriter, r *http.Request) {

go func(i int, url string) {
defer wg.Done()
client := http.Client{Timeout: timeout}
client := http.Client{Transport: transport, Timeout: timeout}
req, err := http.NewRequest(http.MethodGet, url, http.NoBody)
if err != nil {
return
Expand Down

0 comments on commit ae140cf

Please sign in to comment.