Http redirect content-type

I notice that in the http.Redirect function, if the method of the originating request was a GET or a HEAD, then the Content-Type is set to text/html. What is the rationale for this? What is the purpose of setting a Content-Type on a redirect, and what if the page being redirected to, is not of type text/html?

https://golang.org/src/net/http/server.go?s=60163:60228#L2045

Is this logic right?

Thanks

Andy

Just realised that golang sends an html body in the redirect response, containing an anchor element pointing to the redirect location!

What is not clear to me is why the body terminates the anchor with a ‘.’, any idea?

<a href="http://www.example.com/redirect">OK</a>.

https://golang.org/src/net/http/server.go?s=60163:60228#L2055

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