]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef RGW_HTTP_ERRORS_H_ | |
5 | #define RGW_HTTP_ERRORS_H_ | |
6 | ||
7 | #include "rgw_common.h" | |
8 | ||
31f18b77 | 9 | typedef const std::map<int,const std::pair<int, const char*>> rgw_http_errors; |
7c673cae | 10 | |
31f18b77 | 11 | extern rgw_http_errors rgw_http_s3_errors; |
7c673cae | 12 | |
31f18b77 | 13 | extern rgw_http_errors rgw_http_swift_errors; |
7c673cae FG |
14 | |
15 | static inline int rgw_http_error_to_errno(int http_err) | |
16 | { | |
17 | if (http_err >= 200 && http_err <= 299) | |
18 | return 0; | |
19 | switch (http_err) { | |
20 | case 304: | |
21 | return -ERR_NOT_MODIFIED; | |
22 | case 400: | |
23 | return -EINVAL; | |
24 | case 401: | |
25 | return -EPERM; | |
26 | case 403: | |
27 | return -EACCES; | |
28 | case 404: | |
29 | return -ENOENT; | |
30 | case 409: | |
31 | return -ENOTEMPTY; | |
32 | default: | |
33 | return -EIO; | |
34 | } | |
35 | ||
36 | return 0; /* unreachable */ | |
37 | } | |
38 | ||
39 | ||
40 | #endif |