litmus_test_server.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build ignore
  5. /*
  6. This program is a server for the WebDAV 'litmus' compliance test at
  7. http://www.webdav.org/neon/litmus/
  8. To run the test:
  9. go run litmus_test_server.go
  10. and separately, from the downloaded litmus-xxx directory:
  11. make URL=http://localhost:9999/ check
  12. */
  13. package main
  14. import (
  15. "log"
  16. "net/http"
  17. "net/url"
  18. "golang.org/x/net/webdav"
  19. )
  20. func main() {
  21. http.Handle("/", &webdav.Handler{
  22. FileSystem: webdav.NewMemFS(),
  23. LockSystem: webdav.NewMemLS(),
  24. Logger: func(r *http.Request, err error) {
  25. switch r.Method {
  26. case "COPY", "MOVE":
  27. dst := ""
  28. if u, err := url.Parse(r.Header.Get("Destination")); err == nil {
  29. dst = u.Path
  30. }
  31. ow := r.Header.Get("Overwrite")
  32. log.Printf("%-8s%-25s%-25sow=%-2s%v", r.Method, r.URL.Path, dst, ow, err)
  33. default:
  34. log.Printf("%-8s%-30s%v", r.Method, r.URL.Path, err)
  35. }
  36. },
  37. })
  38. const addr = ":9999"
  39. log.Printf("Serving %v", addr)
  40. log.Fatal(http.ListenAndServe(addr, nil))
  41. }