]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: enable users of RGWHTTPClient to get HTTP status code.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 10 Feb 2016 14:36:26 +0000 (15:36 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 22 Feb 2016 15:24:25 +0000 (16:24 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_http_client.cc
src/rgw/rgw_http_client.h

index c233d93a1d7042a48254f41e9b14115620fa16d0..c04a47d9a4ec94d1a6279ce8e8566c062cafe10c 100644 (file)
@@ -118,6 +118,7 @@ int RGWHTTPClient::process(const char *method, const char *url)
     dout(0) << "curl_easy_perform returned error: " << error_buf << dendl;
     ret = -EINVAL;
   }
+  curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_status);
   curl_easy_cleanup(curl_handle);
   curl_slist_free_all(h);
 
index b390911136b010a6e2a11469bee646e6e4502913..3235fe11540d678753d86d10b4306738b1df5a47 100644 (file)
@@ -19,6 +19,7 @@ class RGWHTTPClient
   bufferlist::iterator send_iter;
   size_t send_len;
   bool has_send_len;
+  long http_status;
 
   rgw_http_req_data *req_data;
 
@@ -33,8 +34,18 @@ protected:
   list<pair<string, string> > headers;
   int init_request(const char *method, const char *url, rgw_http_req_data *req_data);
 public:
-  explicit RGWHTTPClient(CephContext *_cct): send_len (0), has_send_len(false), req_data(NULL), user_info(NULL), cct(_cct) {}
+  static const long HTTP_STATUS_NOSTATUS     = 0;
+  static const long HTTP_STATUS_UNAUTHORIZED = 401;
+
   virtual ~RGWHTTPClient();
+  explicit RGWHTTPClient(CephContext *_cct)
+    : send_len(0),
+      has_send_len(false),
+      http_status(HTTP_STATUS_NOSTATUS),
+      req_data(nullptr),
+      user_info(nullptr),
+      cct(_cct) {
+  }
 
   void set_user_info(void *info) {
     user_info = info;
@@ -57,6 +68,10 @@ public:
     has_send_len = true;
   }
 
+  long get_http_status() const {
+    return http_status;
+  }
+
   int process(const char *method, const char *url);
   int process(const char *url) { return process("GET", url); }