mirror of
https://github.com/hacdias/webdav.git
synced 2026-09-25 12:41:54 +08:00
refactor: code cleanup, stricter config validation (#155)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package lib
|
||||
|
||||
import "net/http"
|
||||
|
||||
var _ http.ResponseWriter = responseWriterNoBody{}
|
||||
|
||||
// responseWriterNoBody is a wrapper used to suppress the body of the response
|
||||
// to a request. Mainly used for HEAD requests.
|
||||
type responseWriterNoBody struct {
|
||||
http.ResponseWriter
|
||||
}
|
||||
|
||||
// newResponseWriterNoBody creates a new responseWriterNoBody.
|
||||
func newResponseWriterNoBody(w http.ResponseWriter) *responseWriterNoBody {
|
||||
return &responseWriterNoBody{w}
|
||||
}
|
||||
|
||||
// Write suppress the body.
|
||||
func (w responseWriterNoBody) Write(data []byte) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// WriteHeader writes the header to the http.ResponseWriter.
|
||||
func (w responseWriterNoBody) WriteHeader(statusCode int) {
|
||||
w.Header().Del("Content-Length")
|
||||
w.ResponseWriter.WriteHeader(statusCode)
|
||||
}
|
||||
Reference in New Issue
Block a user