Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httplib2 to requests migration #117

Closed
sfultariya-crest opened this issue Jan 6, 2022 · 0 comments · Fixed by #115
Closed

httplib2 to requests migration #117

sfultariya-crest opened this issue Jan 6, 2022 · 0 comments · Fixed by #115

Comments

@sfultariya-crest
Copy link
Contributor

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:

  1. httplib2 returns (response_headers, content) and requests returns response
  2. 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 the response.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 class ModularAlertBase) is removed in the splunktaucclib v6.0.0. We recommend users to directly use the requests.request function to make the API calls. Doc: https://docs.python-requests.org/en/latest/api/
@sfultariya-crest sfultariya-crest linked a pull request Jan 6, 2022 that will close this issue
sfultariya-crest added a commit that referenced this issue Jan 18, 2022
sfultariya-crest added a commit that referenced this issue Jan 18, 2022
@ghost ghost closed this as completed in #115 Jan 18, 2022
ghost pushed a commit that referenced this issue Jan 18, 2022
@ghost ghost pinned this issue Jan 18, 2022
srv-rr-github-token pushed a commit that referenced this issue Feb 1, 2022
# [6.0.0](v5.0.7...v6.0.0) (2022-02-01)

* feat!: migrate from httplib2 to requests library ([08b895d](08b895d))

### BREAKING CHANGES

* See #117.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant