You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to properly send a 410 Gone response with the net/http package.
I would like to do something like this http.Error(w, "", http.StatusGone).
But after reading the http.Error() function code here we can see that the error response is written with fmt.Fprintln() which add a new line at the end and make the Content-Length header to be 1 instead of 0.
Is there a particular reason here to not just use fmt.Fprint() ?
For now, I simply use:
w.WriteHeader(http.StatusGone)
fmt.Fprint(w, "")
But it would be cleaner if I can just call the http.Error() which seems to be intended for this purpose.
WDYT ?
The text was updated successfully, but these errors were encountered:
Hello!
First, thanks for all your work, it's amazing.
I'm trying to properly send a
410 Gone
response with thenet/http
package.I would like to do something like this
http.Error(w, "", http.StatusGone)
.But after reading the
http.Error()
function code here we can see that the error response is written withfmt.Fprintln()
which add a new line at the end and make theContent-Length
header to be1
instead of0
.Is there a particular reason here to not just use
fmt.Fprint()
?For now, I simply use:
But it would be cleaner if I can just call the
http.Error()
which seems to be intended for this purpose.WDYT ?
The text was updated successfully, but these errors were encountered: