Skip to content

Commit

Permalink
Merge pull request #74 from arista-eosplus/issue-18
Browse files Browse the repository at this point in the history
Issue #18 performance fixes
  • Loading branch information
devrobo committed Jan 4, 2016
2 parents ce506dc + a4b2776 commit 18e2455
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pyeapi/eapilib.py
Expand Up @@ -367,14 +367,17 @@ def send(self, data):
self.transport.putheader('Authorization',
'Basic %s' % (self._auth))

self.transport.endheaders()
if int(sys.version[0]) > 2:
# For Python 3.x compatibility
data = data.encode()

self.transport.send(data)
self.transport.endheaders(message_body=data)

try: # Python 2.7: use buffering of HTTP responses
response = self.transport.getresponse(buffering=True)
except TypeError: # Python 2.6: older, and 3.x on
response = self.transport.getresponse()

response = self.transport.getresponse()
response_content = response.read()
_LOGGER.debug("Response: status: {status}, reason: {reason}".format(
status=response.status,
Expand Down

0 comments on commit 18e2455

Please sign in to comment.