]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: make RGWPostHTTPData able to extract X-Subject-Token.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 2 Feb 2016 15:40:45 +0000 (16:40 +0100)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 19 Feb 2016 20:16:05 +0000 (12:16 -0800)
The change has been extracted from changeset proposed
in commit af71f6a518529ea6cccb25bd46da2b6d1458c1da by
Mark Barnes <mark.barnes@ocado.com> (lperiquito).

Signed-off-by: Mark Barnes <mark.barnes@ocado.com>
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_swift.cc

index c3adedf07017a6fa41836ea83619689ec31905ff..5f3faa63101737032dc297bc1ef95f03fbcfc1cb 100644 (file)
@@ -111,6 +111,7 @@ 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) {}
 
@@ -134,8 +135,41 @@ public:
   }
 
   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, 10) << "read_http_header" << dendl;
+
+    while (s != end) {
+      if (*s == '\r') {
+        s++;
+        continue;
+      }
+      if (*s == '\n') {
+        *p = '\0';
+        ldout(cct, 10) << "os_auth:" << 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 RGWGetKeystoneAdminToken;