Skip to content

Commit 1e73ada

Browse files
committed
changed WSResponse to class, added getheader method to it
1 parent 1e0b05b commit 1e73ada

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

kubernetes/base/stream/ws_client.py

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

256256

257-
WSResponse = collections.namedtuple('WSResponse', ['data', 'status'])
257+
#WSResponse = collections.namedtuple('WSResponse', ['data', 'status', 'getheader'])
258+
class WSResponse:
258259

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

260268
class PortForward:
261269
def __init__(self, websocket, ports):
@@ -536,9 +544,9 @@ def websocket_call(configuration, _method, url, **kwargs):
536544
client.run_forever(timeout=_request_timeout)
537545
all = client.read_all()
538546
if binary:
539-
return WSResponse(data=all, status=0)
547+
return WSResponse(data=all, status=200)
540548
else:
541-
return WSResponse(data='%s' % ''.join(all), status=0)
549+
return WSResponse(data='%s' % ''.join(all), status=200)
542550
except (Exception, KeyboardInterrupt, SystemExit) as e:
543551
raise ApiException(status=0, reason=str(e))
544552

0 commit comments

Comments
 (0)