Merge branch 'master' into develop
This commit is contained in:
		
						commit
						4f450cfd02
					
				
							
								
								
									
										27
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
---
 | 
			
		||||
name: Bug report
 | 
			
		||||
about: Create a report to help us improve
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
Hello Collaborators,
 | 
			
		||||
 | 
			
		||||
**Describe the bug**
 | 
			
		||||
A short description of what you think the bug is.
 | 
			
		||||
 | 
			
		||||
**Software**
 | 
			
		||||
 - OS:
 | 
			
		||||
 - Golang:
 | 
			
		||||
 - Version:
 | 
			
		||||
 | 
			
		||||
**To Reproduce**
 | 
			
		||||
1. Go to '...'
 | 
			
		||||
2. Click on '....'
 | 
			
		||||
3. Scroll down to '....'
 | 
			
		||||
4. See error
 | 
			
		||||
 | 
			
		||||
**Expected**
 | 
			
		||||
A short description of what you expected to happen.
 | 
			
		||||
 | 
			
		||||
**Additional context**
 | 
			
		||||
Add any other context about the problem here.
 | 
			
		||||
							
								
								
									
										24
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								README.md
									
									
									
									
									
								
							@ -253,55 +253,55 @@ func (c *Client) Connect() error
 | 
			
		||||
```
 | 
			
		||||
Connect connects to our dav server
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.Copy">func</a> (\*Client) [Copy](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6960:7028#L314)
 | 
			
		||||
#### <a name="Client.Copy">func</a> (\*Client) [Copy](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6438:6506#L303)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) Copy(oldpath, newpath string, overwrite bool) error
 | 
			
		||||
```
 | 
			
		||||
Copy copies a file from A to B
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.Mkdir">func</a> (\*Client) [Mkdir](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6051:6107#L273)
 | 
			
		||||
#### <a name="Client.Mkdir">func</a> (\*Client) [Mkdir](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5529:5585#L262)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) Mkdir(path string, _ os.FileMode) error
 | 
			
		||||
```
 | 
			
		||||
Mkdir makes a directory
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.MkdirAll">func</a> (\*Client) [MkdirAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6286:6345#L284)
 | 
			
		||||
#### <a name="Client.MkdirAll">func</a> (\*Client) [MkdirAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5764:5823#L273)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) MkdirAll(path string, _ os.FileMode) error
 | 
			
		||||
```
 | 
			
		||||
MkdirAll like mkdir -p, but for webdav
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.Read">func</a> (\*Client) [Read](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7134:7184#L319)
 | 
			
		||||
#### <a name="Client.Read">func</a> (\*Client) [Read](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6612:6662#L308)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) Read(path string) ([]byte, error)
 | 
			
		||||
```
 | 
			
		||||
Read reads the contents of a remote file
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.ReadDir">func</a> (\*Client) [ReadDir](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=3126:3186#L131)
 | 
			
		||||
#### <a name="Client.ReadDir">func</a> (\*Client) [ReadDir](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=2604:2664#L120)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) ReadDir(path string) ([]os.FileInfo, error)
 | 
			
		||||
```
 | 
			
		||||
ReadDir reads the contents of a remote directory
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.ReadStream">func</a> (\*Client) [ReadStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7495:7558#L337)
 | 
			
		||||
#### <a name="Client.ReadStream">func</a> (\*Client) [ReadStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6973:7036#L326)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) ReadStream(path string) (io.ReadCloser, error)
 | 
			
		||||
```
 | 
			
		||||
ReadStream reads the stream for a given path
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.Remove">func</a> (\*Client) [Remove](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5557:5599#L250)
 | 
			
		||||
#### <a name="Client.Remove">func</a> (\*Client) [Remove](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5035:5077#L239)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) Remove(path string) error
 | 
			
		||||
```
 | 
			
		||||
Remove removes a remote file
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.RemoveAll">func</a> (\*Client) [RemoveAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5665:5710#L255)
 | 
			
		||||
#### <a name="Client.RemoveAll">func</a> (\*Client) [RemoveAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5143:5188#L244)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) RemoveAll(path string) error
 | 
			
		||||
```
 | 
			
		||||
RemoveAll removes remote files
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.Rename">func</a> (\*Client) [Rename](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6794:6864#L309)
 | 
			
		||||
#### <a name="Client.Rename">func</a> (\*Client) [Rename](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6272:6342#L298)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) Rename(oldpath, newpath string, overwrite bool) error
 | 
			
		||||
```
 | 
			
		||||
@ -325,19 +325,19 @@ func (c *Client) SetTransport(transport http.RoundTripper)
 | 
			
		||||
```
 | 
			
		||||
SetTransport exposes the ability to define custom transports
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.Stat">func</a> (\*Client) [Stat](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=4513:4568#L198)
 | 
			
		||||
#### <a name="Client.Stat">func</a> (\*Client) [Stat](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=3991:4046#L187)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) Stat(path string) (os.FileInfo, error)
 | 
			
		||||
```
 | 
			
		||||
Stat returns the file stats for a specified path
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.Write">func</a> (\*Client) [Write](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7849:7918#L352)
 | 
			
		||||
#### <a name="Client.Write">func</a> (\*Client) [Write](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7327:7396#L341)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) Write(path string, data []byte, _ os.FileMode) error
 | 
			
		||||
```
 | 
			
		||||
Write writes data to a given path
 | 
			
		||||
 | 
			
		||||
#### <a name="Client.WriteStream">func</a> (\*Client) [WriteStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=8320:8400#L374)
 | 
			
		||||
#### <a name="Client.WriteStream">func</a> (\*Client) [WriteStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7798:7878#L363)
 | 
			
		||||
``` go
 | 
			
		||||
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) error
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								client.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								client.go
									
									
									
									
									
								
							@ -85,18 +85,7 @@ func (c *Client) Connect() error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if rs.StatusCode == 401 && c.auth.Type() == "NoAuth" {
 | 
			
		||||
		if strings.Index(rs.Header.Get("Www-Authenticate"), "Digest") > -1 {
 | 
			
		||||
			c.auth = &DigestAuth{c.auth.User(), c.auth.Pass(), digestParts(rs)}
 | 
			
		||||
		} else if strings.Index(rs.Header.Get("Www-Authenticate"), "Basic") > -1 {
 | 
			
		||||
			c.auth = &BasicAuth{c.auth.User(), c.auth.Pass()}
 | 
			
		||||
		} else {
 | 
			
		||||
			return newPathError("Authorize", c.root, rs.StatusCode)
 | 
			
		||||
		}
 | 
			
		||||
		return c.Connect()
 | 
			
		||||
	} else if rs.StatusCode == 401 {
 | 
			
		||||
		return newPathError("Authorize", c.root, rs.StatusCode)
 | 
			
		||||
	} else if rs.StatusCode != 200 || (rs.Header.Get("Dav") == "" && rs.Header.Get("DAV") == "") {
 | 
			
		||||
	if rs.StatusCode != 200 {
 | 
			
		||||
		return newPathError("Connect", c.root, rs.StatusCode)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@ import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"flag"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	d "github.com/studio-b12/gowebdav"
 | 
			
		||||
	d "github.com/mrvine/gowebdav"
 | 
			
		||||
	"io"
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/user"
 | 
			
		||||
 | 
			
		||||
@ -77,7 +77,12 @@ func getDigestAuthorization(digestParts map[string]string) string {
 | 
			
		||||
	nonceCount := 00000001
 | 
			
		||||
	cnonce := getCnonce()
 | 
			
		||||
	response := getMD5(fmt.Sprintf("%s:%s:%v:%s:%s:%s", ha1, d["nonce"], nonceCount, cnonce, d["qop"], ha2))
 | 
			
		||||
	authorization := fmt.Sprintf(`Digest username="%s", realm="%s", nonce="%s", uri="%s", cnonce="%s", nc="%v", qop="%s", response="%s", opaque="%s"`,
 | 
			
		||||
		d["username"], d["realm"], d["nonce"], d["uri"], cnonce, nonceCount, d["qop"], response, d["opaque"])
 | 
			
		||||
	authorization := fmt.Sprintf(`Digest username="%s", realm="%s", nonce="%s", uri="%s", qop=%s, nc=%v, cnonce="%s", response="%s"`,
 | 
			
		||||
		d["username"], d["realm"], d["nonce"], d["uri"], d["qop"], nonceCount, cnonce, response)
 | 
			
		||||
 | 
			
		||||
	if d["opaque"] != "" {
 | 
			
		||||
		authorization += fmt.Sprintf(`, opaque="%s"`, d["opaque"])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return authorization
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										24
									
								
								requests.go
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								requests.go
									
									
									
									
									
								
							@ -1,6 +1,7 @@
 | 
			
		||||
package gowebdav
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/http"
 | 
			
		||||
@ -8,7 +9,11 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (c *Client) req(method, path string, body io.Reader, intercept func(*http.Request)) (req *http.Response, err error) {
 | 
			
		||||
	r, err := http.NewRequest(method, PathEscape(Join(c.root, path)), body)
 | 
			
		||||
	// Tee the body, because if authorization fails we will need to read from it again.
 | 
			
		||||
	var ba bytes.Buffer
 | 
			
		||||
	bb := io.TeeReader(body, &ba)
 | 
			
		||||
 | 
			
		||||
	r, err := http.NewRequest(method, PathEscape(Join(c.root, path)), &ba)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@ -25,7 +30,22 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
 | 
			
		||||
		intercept(r)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return c.c.Do(r)
 | 
			
		||||
	rs, err := c.c.Do(r)
 | 
			
		||||
 | 
			
		||||
	if rs.StatusCode == 401 && c.auth.Type() == "NoAuth" {
 | 
			
		||||
		if strings.Index(rs.Header.Get("Www-Authenticate"), "Digest") > -1 {
 | 
			
		||||
			c.auth = &DigestAuth{c.auth.User(), c.auth.Pass(), digestParts(rs)}
 | 
			
		||||
		} else if strings.Index(rs.Header.Get("Www-Authenticate"), "Basic") > -1 {
 | 
			
		||||
			c.auth = &BasicAuth{c.auth.User(), c.auth.Pass()}
 | 
			
		||||
		} else {
 | 
			
		||||
			return rs, newPathError("Authorize", c.root, rs.StatusCode)
 | 
			
		||||
		}
 | 
			
		||||
		return c.req(method, path, bb, intercept)
 | 
			
		||||
	} else if rs.StatusCode == 401 {
 | 
			
		||||
		return rs, newPathError("Authorize", c.root, rs.StatusCode)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return rs, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Client) mkcol(path string) int {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user