Keep doing the webdav

This commit is contained in:
zicla
2019-04-18 23:28:18 +08:00
parent 4611735283
commit 0d5300abda
7 changed files with 70 additions and 15 deletions

View File

@ -214,7 +214,7 @@ func props(ctx context.Context, fs FileSystem, ls LockSystem, name string, pname
}
// Propnames returns the property names defined for resource name.
func propnames(ctx context.Context, fs FileSystem, ls LockSystem, name string) ([]xml.Name, error) {
func Propnames(ctx context.Context, fs FileSystem, ls LockSystem, name string) ([]xml.Name, error) {
f, err := fs.OpenFile(ctx, name, os.O_RDONLY, 0)
if err != nil {
return nil, err
@ -255,7 +255,7 @@ func propnames(ctx context.Context, fs FileSystem, ls LockSystem, name string) (
//
// See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND
func allprop(ctx context.Context, fs FileSystem, ls LockSystem, name string, include []xml.Name) ([]Propstat, error) {
pnames, err := propnames(ctx, fs, ls, name)
pnames, err := Propnames(ctx, fs, ls, name)
if err != nil {
return nil, err
}

View File

@ -522,7 +522,7 @@ func TestMemPS(t *testing.T) {
var propstats []Propstat
switch op.op {
case "propname":
pnames, err := propnames(ctx, fs, ls, op.name)
pnames, err := Propnames(ctx, fs, ls, op.name)
if err != nil {
t.Errorf("%s: got error %v, want nil", desc, err)
continue

View File

@ -543,7 +543,7 @@ func (this *Handler) handlePropfind(writer http.ResponseWriter, request *http.Re
reqPath, info.Name(), info.IsDir(), info.Mode(), info.ModTime(), info.Size())
var propstats []Propstat
if pf.Propname != nil {
pnames, err := propnames(ctx, this.FileSystem, this.LockSystem, reqPath)
pnames, err := Propnames(ctx, this.FileSystem, this.LockSystem, reqPath)
if err != nil {
return err
}
@ -570,7 +570,7 @@ func (this *Handler) handlePropfind(writer http.ResponseWriter, request *http.Re
}
walkErr := walkFS(ctx, this.FileSystem, depth, reqPath, fileInfo, walkFn)
closeErr := multiStatusWriter.close()
closeErr := multiStatusWriter.Close()
if walkErr != nil {
return http.StatusInternalServerError, walkErr
}
@ -609,7 +609,7 @@ func (this *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (st
}
mw := MultiStatusWriter{Writer: w}
writeErr := mw.Write(makePropstatResponse(r.URL.Path, pstats))
closeErr := mw.close()
closeErr := mw.Close()
if writeErr != nil {
return http.StatusInternalServerError, writeErr
}

View File

@ -377,7 +377,7 @@ func (this *MultiStatusWriter) writeHeader() error {
// an error if the multistatus response could not be completed. If both the
// return value and field Encoder of w are nil, then no multistatus response has
// been written.
func (this *MultiStatusWriter) close() error {
func (this *MultiStatusWriter) Close() error {
if this.Encoder == nil {
return nil
}

View File

@ -582,7 +582,7 @@ loop:
continue loop
}
}
if err := w.close(); err != tc.wantErr {
if err := w.Close(); err != tc.wantErr {
t.Errorf("%s: got close error %v, want %v",
tc.desc, err, tc.wantErr)
continue