Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / rgw / rgw_http_errors.h
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
9 typedef const std::map<int,const std::pair<int, const char*>> rgw_http_errors;
10
11 extern rgw_http_errors rgw_http_s3_errors;
12
13 extern rgw_http_errors rgw_http_swift_errors;
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