I have a HTTP server in Go in which when client is asking for any file I am serving it using http.ServeFile
. I need to send username and password with this file also. For that I am doing it by first sending a response with fmt.Fprintf
and later I am doing http.ServeFile
.
So it is solving the purpose but it is throwing a warning "http: superfluous response.WriteHeader call". How to resolve this.
Please Note: I need to send username and password with the served file.
if r.URL.Path == "/html/home.html" {
fmt.Fprintf(w, `<!DOCTYPE HTML>
<html><div><input id="username" type="hidden" readonly value="%s" />
<br><input id="password" type="hidden" readonly value="%s" /><div>`,
name, password)
http.ServeFile(w, r, r.URL.Path[1:])
}