Skip to content
Permalink
Browse files

Updates after review - Comments from Qalthos

  • Loading branch information...
Miguel A. Munoz
Miguel A. Munoz committed Jun 11, 2019
1 parent 4531c47 commit d641bd6490bed7265adfbad0ce513e52ee028d04
Showing with 7 additions and 8 deletions.
  1. +7 −8 lib/ansible/plugins/httpapi/fortios.py
@@ -53,9 +53,6 @@ class HttpApi(HttpApiBase):
def __init__(self, connection):
super(HttpApi, self).__init__(connection)

self._connection = connection
self._become = False
self._become_pass = ''
self._ccsrftoken = ''

def set_become(self, become_context):
@@ -84,21 +81,22 @@ def update_auth(self, response, response_text):
Get cookies and obtain value for csrftoken that will be used on next requests
:param response: Response given by the server.
:param response_text Unused_input.
:return: Dictionary containing cookies
:return: Dictionary containing headers
"""

cookies = {}
headers = {}

for attr, val in response.getheaders():
if attr == 'Set-Cookie' and 'APSCOOKIE_' in val:
cookies['Cookie'] = val
headers['Cookie'] = val

elif attr == 'Set-Cookie' and 'ccsrftoken=' in val:
csrftoken_search = re.search('\"(.*)\"', val)
if csrftoken_search:
self._ccsrftoken = csrftoken_search.group(1)
headers['x-csrftoken'] = self._ccsrftoken

return cookies
return headers

def handle_httperror(self, exc):
"""
@@ -108,6 +106,7 @@ def handle_httperror(self, exc):
"""
return exc


def send_request(self, **message_kwargs):
"""
Responsible for actual sending of data to the connection httpapi base plugin.
@@ -130,7 +129,7 @@ def send_request(self, **message_kwargs):
headers['Content-Type'] = 'application/json'

try:
response, response_data = self._connection.send(url, data, headers=headers, method=method)
response, response_data = self.connection.send(url, data, headers=headers, method=method)

return response.status, to_text(response_data.getvalue())
except Exception as err:

0 comments on commit d641bd6

Please sign in to comment.
You can’t perform that action at this time.