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
Add requests.Session like class #37622
Conversation
Cleaner diff: https://github.com/ansible/ansible/pull/37622/files?w=1 |
c988048
to
d1435bf
Compare
As is, this should now pass all current tests. However, I need more tests. |
This comment has been minimized.
This comment has been minimized.
Removed WIP. This has complete tests. |
… test to validate funcitonality
@bcoca are you good with this feature making it in for 2.7? |
fine with me, i was thinking more of a 'sessions' vs emulating requests, but that is just bikeshed |
* Adds requests.Session like class * py2 syntax fix * Add a few examples to the Request docstrings * Add helper methods and docs * Fix test failures * Switch tests to test Request instead of open_url, add simple open_url test to validate funcitonality * Fix filename in replace-urlopen code smell test
|
||
Does not require the module environment | ||
''' | ||
method = method or 'GET' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sivel @bcoca Breaking change incoming here! From the documentation of urllib.request:
method should be a string that indicates the HTTP request method that will be used (e.g. 'HEAD'). If provided, its value is stored in the method attribute and is used by get_method(). The default is 'GET' if data is None or 'POST' otherwise.
This PR changes the default to always be 'GET' which breaks at least the rocketchat notification module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also breaks the rollbar_deployment
module, see pull request #42876
SUMMARY
Adds a simple class that adds session like functionality. Uses a common cookiejar across requests, and has "default" value support across requests.
Needs tests and stuff
ISSUE TYPE
COMPONENT NAME
lib/ansible/module_utils/urls.py
ANSIBLE VERSION
ADDITIONAL INFORMATION