This repository has been archived by the owner on Dec 12, 2018. It is now read-only.
forked from der-antikeks/go-webdav
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathconstants.go
65 lines (58 loc) · 2.23 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package webdav
import (
"errors"
"net/http"
)
// status codes
const (
StatusOK = http.StatusOK
StatusCreated = http.StatusCreated
StatusAccepted = http.StatusAccepted
StatusNoContent = http.StatusNoContent
StatusMovedPermanently = http.StatusMovedPermanently
StatusMovedTemporarily = 302 // TODO: duplicate of http.StatusFound ?
StatusNotModified = http.StatusNotModified
StatusBadRequest = http.StatusBadRequest
StatusUnauthorized = http.StatusUnauthorized
StatusForbidden = http.StatusForbidden
StatusNotFound = http.StatusNotFound
StatusInternalServerError = http.StatusInternalServerError
StatusNotImplemented = http.StatusNotImplemented
StatusBadGateway = http.StatusBadGateway
StatusServiceUnavailable = http.StatusServiceUnavailable
StatusContinue = http.StatusContinue
StatusMethodNotAllowed = http.StatusMethodNotAllowed
StatusConflict = http.StatusConflict
StatusPreconditionFailed = http.StatusPreconditionFailed
StatusRequestTooLong = http.StatusRequestEntityTooLarge
StatusUnsupportedMediaType = http.StatusUnsupportedMediaType
)
// extended status codes, http://www.webdav.org/specs/rfc4918.html#status.code.extensions.to.http11
const (
StatusMulti = 207
StatusUnprocessableEntity = 422
StatusLocked = 423
StatusFailedDependency = 424
StatusInsufficientStorage = 507
)
var statusText = map[int]string{
StatusMovedTemporarily: "Moved Temporarily",
StatusMulti: "Multi-Status",
StatusUnprocessableEntity: "Unprocessable Entity",
StatusLocked: "Locked",
StatusFailedDependency: "Failed Dependency",
StatusInsufficientStorage: "Insufficient Storage",
}
// StatusText returns a text for the HTTP status code. It returns the empty string if the code is unknown.
func StatusText(code int) string {
if t, ok := statusText[code]; ok {
return t
}
return http.StatusText(code)
}
// internal error variables
var (
ErrInvalidCharPath = errors.New("invalid character in file path")
ErrNotImplemented = errors.New("feature not yet implemented")
ErrMalformedXml = errors.New("xml is not well-formed")
)