From: Radoslaw Zarzynski Date: Wed, 10 Feb 2016 14:36:26 +0000 (+0100) Subject: rgw: enable users of RGWHTTPClient to get HTTP status code. X-Git-Tag: v10.1.0~304^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=19843ce2b5c20e3820548d0b3f73ad9e4f2bc315;p=ceph.git rgw: enable users of RGWHTTPClient to get HTTP status code. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index c233d93a1d7..c04a47d9a4e 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -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); diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index b390911136b..3235fe11540 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -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 > 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); }