diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2023-06-13 10:51:42 +0200 |
---|---|---|
committer | Jose M. Guisado <jguisado@soleta.eu> | 2023-06-14 14:50:55 +0200 |
commit | 0c03d82ca8792e5e0c41460f3aa5cdf6990a3412 (patch) | |
tree | 10e7e6d2433a46c945b6ffa3e7e574264b3295cb /src/restRequest.py | |
parent | 926a73cf33896ae62f8255a8f2aca2e0d9a54038 (diff) |
ogclient: add support for X-Sequence headerv1.3.0
Enable parsing of "X-Sequence" HTTP headers from incoming requests.
Add "seq" field in restRequest class.
Enable adding "X-Sequence" to outgoing responses.
Add "seq" field inside restResponse class.
Store current client sequence number inside ogClient class.
Ideally, the restRequest object should be used to retrieve the
sequence number but not all processing functions inside ogRest.py
receive the request as parameter (eg: process_refresh).
In the other hand, all processing functions receive the ogClient object.
Diffstat (limited to 'src/restRequest.py')
-rw-r--r-- | src/restRequest.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/restRequest.py b/src/restRequest.py index 61d64c6..b14ad20 100644 --- a/src/restRequest.py +++ b/src/restRequest.py @@ -35,6 +35,7 @@ class restRequest: self.id = None self.echo = None self.code = None + self.seq = None def parser(self,data): self.request_line, self.headers_alone = data.split('\n', 1) @@ -49,6 +50,10 @@ class restRequest: if 'Content-Length' in self.headers.keys(): self.content_len = int(self.headers['Content-Length']) + if 'X-Sequence' in self.headers.keys(): + self.seq = int(self.headers['X-Sequence']) + logging.debug(f'Request with sequence number {self.seq}') + if (not self.request_line == None or not self.request_line == ''): self.method = self.request_line.split('/', 1)[0] self.URI = self.request_line.split('/', 1)[1] |