I have been looking for a way to have custom reasons phrases for non-standard HTTP status codes, and can not find a reasonably clean way of doing it.
Currently, the text for standard responses is defined in net/http/status.go#statusText, exported via the http.StatusText() function, but used directly within the net/http package, to build the status line in the non-exported function net/http/server.go#statusLine() function. This private function is, in turn, used in the private chunkWriter.writeHeader() method.
This has already been a visible problem for the supplementary Golang network libraries : WebDav needs a number of such custom responses, and the authors of the
golang.org/x/net/webdav/webdav.go have had to start high up the HTTP stack by reimplementing *Handler.ServerHTTP(), using their own StatusText in that implementation to work around this limitation.
In another approach for the same issu, Camlistore just forcibly writes its custom 207 response for the PROPFIND verb using ResponseWriter.WriteHeader() without setting a reason.
Did we all miss something here ? Is there a decision not to support such custom responses ? It seems the custom logic implemented by chunkWriter.writeHeader() is something a non-core program should not have to rewrite for such a simple purpose.