return ret;
}
-int RGWHTTPClient::process(const char *method, const char *url)
+static curl_slist *headers_to_slist(list<pair<string, string> >& headers)
{
- int ret = 0;
- CURL *curl_handle;
-
- char error_buf[CURL_ERROR_SIZE];
-
- curl_handle = curl_easy_init();
-
- dout(20) << "sending request to " << url << dendl;
-
curl_slist *h = NULL;
list<pair<string, string> >::iterator iter;
if (strncmp(val.c_str(), "HTTP_", 5) == 0) {
val = val.substr(5);
}
+
+ /* we need to convert all underscores into dashes as some web servers forbid them
+ * in the http header field names
+ */
+ for (size_t i = 0; i < val.size(); i++) {
+ if (val[i] == '_') {
+ val[i] = '-';
+ }
+ }
+
val.append(": ");
val.append(p.second);
h = curl_slist_append(h, val.c_str());
}
+ return h;
+}
+
+int RGWHTTPClient::process(const char *method, const char *url)
+{
+ int ret = 0;
+ CURL *curl_handle;
+
+ char error_buf[CURL_ERROR_SIZE];
+
+ curl_handle = curl_easy_init();
+
+ dout(20) << "sending request to " << url << dendl;
+
+ curl_slist *h = headers_to_slist(headers);
+
curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, method);
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
dout(20) << "sending request to " << url << dendl;
- curl_slist *h = NULL;
-
- list<pair<string, string> >::iterator iter;
- for (iter = headers.begin(); iter != headers.end(); ++iter) {
- pair<string, string>& p = *iter;
- string val = p.first;
-
- if (strncmp(val.c_str(), "HTTP_", 5) == 0) {
- val = val.substr(5);
- }
- val.append(": ");
- val.append(p.second);
- h = curl_slist_append(h, val.c_str());
- }
+ curl_slist *h = headers_to_slist(headers);
req_data->h = h;