-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
httpapi: let httpapi plugin handle HTTPErrors other than 401 #43436
Conversation
The test
|
lib/ansible/plugins/httpapi/nxos.py
Outdated
)) | ||
|
||
try: | ||
response_data = json.loads(response_data.getvalue()) |
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 might fail on python 3 and json.loads expects string and getvalue() will return bytes .
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.
On 3.5, yeah... I'll fix that
A bit off topic. Can you please also take care of below small change otherwise it is modifying headers passed to send() .
|
The last commit can stay or go... it does add a bit of complexity, but it also means that the whole business of dealing with HTTP status codes is customizable in a flexible way. Edit: by 'The last commit', I am now referring to the commit following this comment, as it needed an edit. |
but let httpapi plugin have a say on how it happens
|
||
response_text = response.read() | ||
response_buffer = BytesIO() | ||
response_buffer.write(response.read()) |
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.
@Qalthos In case we were downloading big file then we were seeing update_auth() crash while trying to json.loads of response_data. so one idea was to not look at response_data in each sent request. so we update auth data inside http_plugin
CiscoDevNet/FTDAnsible@54ea3cb
with this, we don't need to read response in update_auth. So if you wish we can convert logic to send only response from send() like earlier and client can do read() or chunk read whatever they wish to ?
SUMMARY
ISSUE TYPE
COMPONENT NAME
httpapi
ANSIBLE VERSION