Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/uhttp/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ func (uat *debugTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return resp, nil
}

type cacheControlTripper struct {
next http.RoundTripper
}

func (cct *cacheControlTripper) RoundTrip(req *http.Request) (*http.Response, error) {
if req.Method == http.MethodPost {
req.Header.Set("Cache-Control", "no-store, no-cache, must-revalidate")
req.Header.Set("Pragma", "no-cache")
req.Header.Set("Expires", "0")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use RFC-compliant date format for Expires header.

The value "0" is not RFC 7234 compliant. While many caches may accept it, a proper HTTP-date format should be used.

Apply this diff to use a standards-compliant value:

-		req.Header.Set("Expires", "0")
+		req.Header.Set("Expires", "Thu, 01 Jan 1970 00:00:00 GMT")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
req.Header.Set("Expires", "0")
req.Header.Set("Expires", "Thu, 01 Jan 1970 00:00:00 GMT")
🤖 Prompt for AI Agents
In pkg/uhttp/transport.go around line 186, the Expires header is set to the
non‑RFC value "0"; replace that with an RFC‑compliant HTTP-date string (e.g.,
the Unix epoch or a past date) formatted using Go's http.TimeFormat (RFC1123
with GMT) so caches interpret it correctly, and add the time import if it isn't
already present.

}
return cct.next.RoundTrip(req)
}

type tokenSourceTripper struct {
next http.RoundTripper
tokenSource oauth2.TokenSource
Expand Down Expand Up @@ -215,6 +228,7 @@ func (t *Transport) make(ctx context.Context) (http.RoundTripper, error) {
var rv http.RoundTripper = baseTransport
t.userAgent = fmt.Sprintf("%s cone", t.userAgent)
rv = &debugTripper{next: rv, debug: t.debug}
rv = &cacheControlTripper{next: rv}
rv = &userAgentTripper{next: rv, userAgent: t.userAgent}
rv = &tokenSourceTripper{next: rv, tokenSource: t.tokenSource}
rv = &requestSourceTripper{next: rv, requestSource: t.requestSource}
Expand Down
Loading