diff --git a/webapp/graphite/tags/http.py b/webapp/graphite/tags/http.py index db9bda68c..b7f1f5e02 100644 --- a/webapp/graphite/tags/http.py +++ b/webapp/graphite/tags/http.py @@ -23,10 +23,20 @@ def request(self, method, url, fields, requestContext=None): if 'Authorization' not in headers and self.username and self.password: headers['Authorization'] = 'Basic ' + ('%s:%s' % (self.username, self.password)).encode('base64') + req_fields = [] + for (field, value) in fields.items(): + if value is None: + continue + + if isinstance(value, list) or isinstance(value, tuple): + req_fields.extend([(field, v) for v in value if v is not None]) + else: + req_fields.append((field, value)) + result = http.request( method, self.base_url + url, - fields={field: value for (field, value) in fields.items() if value is not None}, + fields=req_fields, headers=headers, timeout=self.settings.REMOTE_FIND_TIMEOUT, ) diff --git a/webapp/tests/test_tags.py b/webapp/tests/test_tags.py index 6da3bdf5e..438a5dad8 100644 --- a/webapp/tests/test_tags.py +++ b/webapp/tests/test_tags.py @@ -308,10 +308,17 @@ def mockRequest(method, url, fields=None, headers=None, timeout=None): else: self.assertEqual(headers, {}) + req_fields = {} + for (field, value) in fields: + if field in req_fields: + req_fields[field].append(value) + else: + req_fields[field] = [value] + if method == 'POST': - result = self.client.post(url, fields) + result = self.client.post(url, req_fields) elif method == 'GET': - result = self.client.get(url, fields) + result = self.client.get(url, req_fields) else: raise Exception('Invalid HTTP method %s' % method)