| 82 | } |
| 83 | |
| 84 | func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) { |
| 85 | depth := "infinity" |
| 86 | if ld.ZeroDepth { |
| 87 | depth = "0" |
| 88 | } |
| 89 | timeout := ld.Duration / time.Second |
| 90 | return fmt.Fprintf(w, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+ |
| 91 | "<D:prop xmlns:D=\"DAV:\"><D:lockdiscovery><D:activelock>\n"+ |
| 92 | " <D:locktype><D:write/></D:locktype>\n"+ |
| 93 | " <D:lockscope><D:exclusive/></D:lockscope>\n"+ |
| 94 | " <D:depth>%s</D:depth>\n"+ |
| 95 | " <D:owner>%s</D:owner>\n"+ |
| 96 | " <D:timeout>Second-%d</D:timeout>\n"+ |
| 97 | " <D:locktoken><D:href>%s</D:href></D:locktoken>\n"+ |
| 98 | " <D:lockroot><D:href>%s</D:href></D:lockroot>\n"+ |
| 99 | "</D:activelock></D:lockdiscovery></D:prop>", |
| 100 | depth, ld.OwnerXML, timeout, escape(token), escape(ld.Root), |
| 101 | ) |
| 102 | } |
| 103 | |
| 104 | func escape(s string) string { |
| 105 | for i := 0; i < len(s); i++ { |