Clone a http.Request?

I want to copy a http.Request to send a preflight HEAD (with If-Modified-Since etc - this is for a caching Doer). There’s no req.Clone(). How am I supposed to do this? Want to preserve any other headers.

Why not just send the request with the if-modified-since header?

Sorry, it wouldn’t actually be an If-Modified-Since header - the server has the misbehavior known as “WordPress” and will never respond with a 304 (since even if the article body doesn’t change, the rest of the page might, and I’m only interested in the article body)

Therefore, I actually need to preflight a HEAD to save any network traffic. (Probably won’t save any server load though. :confounded:)

If the server ignores cache headers why do you need to copy the request to
retain them. You can get the URL of the original request, so just make a
function that takes a request and returns a HEAD variant

1 Like

Right, i was overengineering this and thinking about cookies, auth etc. I’ll just copy those headers if it turns out I need to use them.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.