Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return actual status codes instead of 400 #52

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,11 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
}

func (c *Client) mkcol(path string) int {
rs, err := c.req("MKCOL", path, nil, nil)
if err != nil {
rs, _ := c.req("MKCOL", path, nil, nil)
zekroTJA marked this conversation as resolved.
Show resolved Hide resolved
if rs == nil {
return 400
}
defer rs.Body.Close()

if rs.StatusCode == 201 || rs.StatusCode == 405 {
return 201
}
zekroTJA marked this conversation as resolved.
Show resolved Hide resolved

return rs.StatusCode
}

Expand Down Expand Up @@ -137,15 +132,15 @@ func (c *Client) propfind(path string, self bool, body string, resp interface{},
}

func (c *Client) doCopyMove(method string, oldpath string, newpath string, overwrite bool) (int, io.ReadCloser) {
rs, err := c.req(method, oldpath, nil, func(rq *http.Request) {
rs, _ := c.req(method, oldpath, nil, func(rq *http.Request) {
rq.Header.Add("Destination", Join(c.root, newpath))
if overwrite {
rq.Header.Add("Overwrite", "T")
} else {
rq.Header.Add("Overwrite", "F")
}
})
if err != nil {
if rs == nil {
return 400, nil
}
return rs.StatusCode, rs.Body
Expand Down Expand Up @@ -178,12 +173,11 @@ func (c *Client) copymove(method string, oldpath string, newpath string, overwri
}

func (c *Client) put(path string, stream io.Reader) int {
rs, err := c.req("PUT", path, stream, nil)
if err != nil {
rs, _ := c.req("PUT", path, stream, nil)
if rs == nil {
return 400
}
defer rs.Body.Close()

return rs.StatusCode
}

Expand Down