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