summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rgw/rgw_http_client.h77
-rw-r--r--src/rgw/rgw_swift.cc70
2 files changed, 77 insertions, 70 deletions
diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h
index 3715a6930c5..bb2c1ccdae6 100644
--- a/src/rgw/rgw_http_client.h
+++ b/src/rgw/rgw_http_client.h
@@ -148,6 +148,83 @@ protected:
};
+#if 1
+// FIXME!
+#define dout_subsys ceph_subsys_rgw
+class RGWPostHTTPData : public RGWHTTPClient {
+ bufferlist *bl;
+ std::string post_data;
+ size_t post_data_index;
+ std::string subject_token;
+public:
+ RGWPostHTTPData(CephContext *_cct, bufferlist *_bl) : RGWHTTPClient(_cct), bl(_bl), post_data_index(0) {}
+ RGWPostHTTPData(CephContext *_cct, bufferlist *_bl, bool verify_ssl) : RGWHTTPClient(_cct), bl(_bl), post_data_index(0){
+ set_verify_ssl(verify_ssl);
+ }
+
+ void set_post_data(const std::string& _post_data) {
+ this->post_data = _post_data;
+ }
+
+ int send_data(void* ptr, size_t len) {
+ int length_to_copy = 0;
+ if (post_data_index < post_data.length()) {
+ length_to_copy = min(post_data.length() - post_data_index, len);
+ memcpy(ptr, post_data.data() + post_data_index, length_to_copy);
+ post_data_index += length_to_copy;
+ }
+ return length_to_copy;
+ }
+
+ int receive_data(void *ptr, size_t len) {
+ bl->append((char *)ptr, len);
+ return 0;
+ }
+
+ int receive_header(void *ptr, size_t len) {
+ char line[len + 1];
+
+ char *s = (char *)ptr, *end = (char *)ptr + len;
+ char *p = line;
+ ldout(cct, 20) << "RGWPostHTTPData::receive_header parsing HTTP headers" << dendl;
+
+ while (s != end) {
+ if (*s == '\r') {
+ s++;
+ continue;
+ }
+ if (*s == '\n') {
+ *p = '\0';
+ ldout(cct, 20) << "RGWPostHTTPData::receive_header: line="
+ << line << dendl;
+ // TODO: fill whatever data required here
+ char *l = line;
+ char *tok = strsep(&l, " \t:");
+ if (tok) {
+ while (l && *l == ' ') {
+ l++;
+ }
+
+ if (strcasecmp(tok, "X-Subject-Token") == 0) {
+ subject_token = l;
+ }
+ }
+ }
+ if (s != end) {
+ *p++ = *s++;
+ }
+ }
+ return 0;
+ }
+
+ std::string get_subject_token() {
+ return subject_token;
+ }
+};
+#undef dout_subsys
+#endif
+
+
class RGWCompletionManager;
class RGWHTTPManager {
diff --git a/src/rgw/rgw_swift.cc b/src/rgw/rgw_swift.cc
index 0fdb310f30e..20412992666 100644
--- a/src/rgw/rgw_swift.cc
+++ b/src/rgw/rgw_swift.cc
@@ -104,76 +104,6 @@ int RGWSwift::validate_token(const char *token, struct rgw_swift_auth_info *info
return 0;
}
-class RGWPostHTTPData : public RGWHTTPClient {
- bufferlist *bl;
- std::string post_data;
- size_t post_data_index;
- std::string subject_token;
-public:
- RGWPostHTTPData(CephContext *_cct, bufferlist *_bl) : RGWHTTPClient(_cct), bl(_bl), post_data_index(0) {}
- RGWPostHTTPData(CephContext *_cct, bufferlist *_bl, bool verify_ssl) : RGWHTTPClient(_cct), bl(_bl), post_data_index(0){
- set_verify_ssl(verify_ssl);
- }
-
- void set_post_data(const std::string& _post_data) {
- this->post_data = _post_data;
- }
-
- int send_data(void* ptr, size_t len) {
- int length_to_copy = 0;
- if (post_data_index < post_data.length()) {
- length_to_copy = min(post_data.length() - post_data_index, len);
- memcpy(ptr, post_data.data() + post_data_index, length_to_copy);
- post_data_index += length_to_copy;
- }
- return length_to_copy;
- }
-
- int receive_data(void *ptr, size_t len) {
- bl->append((char *)ptr, len);
- return 0;
- }
-
- int receive_header(void *ptr, size_t len) {
- char line[len + 1];
-
- char *s = (char *)ptr, *end = (char *)ptr + len;
- char *p = line;
- ldout(cct, 20) << "RGWPostHTTPData::receive_header parsing HTTP headers" << dendl;
-
- while (s != end) {
- if (*s == '\r') {
- s++;
- continue;
- }
- if (*s == '\n') {
- *p = '\0';
- ldout(cct, 20) << "RGWPostHTTPData::receive_header: line="
- << line << dendl;
- // TODO: fill whatever data required here
- char *l = line;
- char *tok = strsep(&l, " \t:");
- if (tok) {
- while (l && *l == ' ') {
- l++;
- }
-
- if (strcasecmp(tok, "X-Subject-Token") == 0) {
- subject_token = l;
- }
- }
- }
- if (s != end) {
- *p++ = *s++;
- }
- }
- return 0;
- }
-
- std::string get_subject_token() {
- return subject_token;
- }
-};
typedef RGWPostHTTPData RGWValidateKeystoneToken;
typedef RGWPostHTTPData RGWGetKeystoneAdminToken;