Skip to content

Commit e5402ee

Browse files
authored
Merge pull request #262 from billmurrin/hotfix/261-context-request-get-parameters
properly add parameters to request based on the method of the request
2 parents 5267fea + 19d59c6 commit e5402ee

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

splunklib/binding.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, *
764764

765765
@_authentication
766766
@_log_duration
767-
def request(self, path_segment, method="GET", headers=None, body="",
767+
def request(self, path_segment, method="GET", headers=None, body={},
768768
owner=None, app=None, sharing=None):
769769
"""Issues an arbitrary HTTP request to the REST path segment.
770770
@@ -824,13 +824,28 @@ def request(self, path_segment, method="GET", headers=None, body="",
824824
path = self.authority \
825825
+ self._abspath(path_segment, owner=owner,
826826
app=app, sharing=sharing)
827+
827828
all_headers = headers + self.additional_headers + self._auth_headers
828829
logging.debug("%s request to %s (headers: %s, body: %s)",
829830
method, path, str(all_headers), repr(body))
830-
response = self.http.request(path,
831-
{'method': method,
832-
'headers': all_headers,
833-
'body': body})
831+
832+
if body:
833+
body = _encode(**body)
834+
835+
if method == "GET":
836+
path = path + UrlEncoded('?' + body, skip_encode=True)
837+
message = {'method': method,
838+
'headers': all_headers}
839+
else:
840+
message = {'method': method,
841+
'headers': all_headers,
842+
'body': body}
843+
else:
844+
message = {'method': method,
845+
'headers': all_headers}
846+
847+
response = self.http.request(path, message)
848+
834849
return response
835850

836851
def login(self):

0 commit comments

Comments
 (0)