Skip to content

Commit 2c5775a

Browse files
committed
changed WSResponse to class, added getheader method as api_client
expects it like RESTResponse.
1 parent 87bfa84 commit 2c5775a

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

kubernetes/base/stream/ws_client.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,15 @@ def close(self, **kwargs):
254254
self.sock.close(**kwargs)
255255

256256

257-
WSResponse = collections.namedtuple('WSResponse', ['data'])
257+
class WSResponse:
258258

259+
def __init__(self, data, status):
260+
self.status = status
261+
self.data = data
262+
263+
def getheader(self, name, default=None):
264+
"""Returns a given response header."""
265+
return None
259266

260267
class PortForward:
261268
def __init__(self, websocket, ports):
@@ -536,9 +543,9 @@ def websocket_call(configuration, _method, url, **kwargs):
536543
client.run_forever(timeout=_request_timeout)
537544
all = client.read_all()
538545
if binary:
539-
return WSResponse(all)
546+
return WSResponse(data=all, status=200)
540547
else:
541-
return WSResponse('%s' % ''.join(all))
548+
return WSResponse(data='%s' % ''.join(all), status=200)
542549
except (Exception, KeyboardInterrupt, SystemExit) as e:
543550
raise ApiException(status=0, reason=str(e))
544551

0 commit comments

Comments
 (0)