summaryrefslogtreecommitdiffstats
path: root/src/ogClient.py
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2021-07-15 11:31:44 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-07-15 13:08:43 +0200
commitc61964fa8573572be6812653453efc8da630e521 (patch)
treedf6e9b59b376fcafdf17195d0e141e97dbf3854e /src/ogClient.py
parent79408870680c7d9fa623b2b8022308aed9956038 (diff)
#1056 add cleanup method and use it
add method to clean up interval socket state and use it
Diffstat (limited to 'src/ogClient.py')
-rw-r--r--src/ogClient.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/ogClient.py b/src/ogClient.py
index fe4e591..1457575 100644
--- a/src/ogClient.py
+++ b/src/ogClient.py
@@ -47,6 +47,12 @@ class ogClient:
def get_state(self):
return self.state
+ def cleanup(self):
+ self.data = ""
+ self.content_len = 0
+ self.header_len = 0
+ self.trailer = False
+
def connect(self):
print('connecting...')
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -57,10 +63,7 @@ class ogClient:
self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 4)
self.state = State.CONNECTING
- self.data = ""
- self.trailer = False
- self.content_len = 0
- self.header_len = 0
+ self.cleanup()
try:
self.sock.connect((self.ip, self.port))
@@ -121,12 +124,7 @@ class ogClient:
if self.trailer and (len(self.data) >= self.content_len + self.header_len):
request.parser(self.data)
self.ogrest.process_request(request, self)
-
- # Cleanup state information from request
- self.data = ""
- self.content_len = 0
- self.header_len = 0
- self.trailer = False
+ self.cleanup()
def disconnect(self):
self.state = State.FORCE_DISCONNECTED