Closed
Description
Currently, splunktaucclib
uses the httplib2
internally to make the API calls. In the next release of splunktaucclib (6.0.0), we will be replacing the httplib2
library with the requests
library. This issue provides the change details.
Difference between httplib2
and requests
:
- httplib2 returns
(response_headers, content)
and requests returnsresponse
- In httplib2, the
content
is a type of bytes object which needs to be converted into an str object. In requests, we can directly get the str object using theresponse.text
Example:
Using httplib2
:
import httplib2
h = httplib2.Http()
(response_headers, content) = h.request("http://example.org/", "GET")
print(response_headers.status)
data = content.decode('utf-8')
Using requests
:
import requests
response = requests.request("GET", "http://example.org/")
print(response.status_code)
data = response.text
Code change require to use the splunktaucclib v6.0.0
Note: If you are using the splunktaucclib.alert_actions_base.ModularAlertBase
class directly in your code then you need to make the below change in your source code to use the splunktaucclib v6.0.0.
- The implementation of
build_http_connection
method (of classModularAlertBase
) is removed in the splunktaucclib v6.0.0. We recommend users to directly use therequests.request
function to make the API calls. Doc: https://docs.python-requests.org/en/latest/api/
Metadata
Metadata
Assignees
Labels
No labels