My Go server is handling requests I first make a call to
response.WriteHeader() in order to set the status code for my response. After that I begin writing bytes into the response body. If the browser cancels the request while i'm copying the bytes, I get an error:
write tcp [::1]:52319: broken pipe
My code detects this error, then calls
http.Error(). This calls
This appears to be a problem, but I'm not sure. Can this be avoided? How do I avoid calling
response.WriteHeader() again when an error occurs while writing to to the response body?