aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/headers.go2
-rw-r--r--internal/ogtags/fetch.go8
-rw-r--r--internal/test/playwright_test.go8
3 files changed, 12 insertions, 6 deletions
diff --git a/internal/headers.go b/internal/headers.go
index bdb5e9e..eb7778b 100644
--- a/internal/headers.go
+++ b/internal/headers.go
@@ -73,7 +73,7 @@ func NoStoreCache(next http.Handler) http.Handler {
})
}
-// Do not allow browsing directory listings in paths that end with /
+// NoBrowsing prevents directory browsing by returning a 404 for any request that ends with a "/".
func NoBrowsing(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/") {
diff --git a/internal/ogtags/fetch.go b/internal/ogtags/fetch.go
index d4db711..7e02eca 100644
--- a/internal/ogtags/fetch.go
+++ b/internal/ogtags/fetch.go
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"golang.org/x/net/html"
+ "io"
"log/slog"
"mime"
"net"
@@ -26,7 +27,12 @@ func (c *OGTagCache) fetchHTMLDocument(urlStr string) (*html.Node, error) {
return nil, fmt.Errorf("http get failed: %w", err)
}
// this defer will call MaxBytesReader's Close, which closes the original body.
- defer resp.Body.Close()
+ defer func(Body io.ReadCloser) {
+ err := Body.Close()
+ if err != nil {
+ slog.Debug("og: error closing response body", "url", urlStr, "error", err)
+ }
+ }(resp.Body)
if resp.StatusCode != http.StatusOK {
slog.Debug("og: received non-OK status code", "url", urlStr, "status", resp.StatusCode)
diff --git a/internal/test/playwright_test.go b/internal/test/playwright_test.go
index 69652ce..8656f76 100644
--- a/internal/test/playwright_test.go
+++ b/internal/test/playwright_test.go
@@ -378,14 +378,14 @@ func pwFail(t *testing.T, page playwright.Page, format string, args ...any) erro
}
func pwTimeout(tc testCase, deadline time.Time) *float64 {
- max := *playwrightMaxTime
+ maxTime := *playwrightMaxTime
if tc.isHard {
- max = *playwrightMaxHardTime
+ maxTime = *playwrightMaxHardTime
}
d := time.Until(deadline)
- if d <= 0 || d > max {
- return playwright.Float(float64(max.Milliseconds()))
+ if d <= 0 || d > maxTime {
+ return playwright.Float(float64(maxTime.Milliseconds()))
}
return playwright.Float(float64(d.Milliseconds()))
}