diff options
author | Radoslaw Zarzynski <rzarzynski@mirantis.com> | 2016-04-04 19:20:17 +0200 |
---|---|---|
committer | Radoslaw Zarzynski <rzarzynski@mirantis.com> | 2016-06-02 15:12:10 +0200 |
commit | 8a2ba268470cc20cb1614fc9f9e343243e50840f (patch) | |
tree | 5ecce8b7c8123d983c8c1f2d060f8c10697e487d /src/rgw/rgw_http_client.h | |
parent | rgw: implement RGWHTTPHeadersCollector. (diff) | |
download | ceph-8a2ba268470cc20cb1614fc9f9e343243e50840f.tar.xz ceph-8a2ba268470cc20cb1614fc9f9e343243e50840f.zip |
rgw: ONLY move RGWPostHTTPData to rgw_http_client.h.
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
Diffstat (limited to 'src/rgw/rgw_http_client.h')
-rw-r--r-- | src/rgw/rgw_http_client.h | 77 |
1 files changed, 77 insertions, 0 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 { |