Skip to content

Commit

Permalink
merge OrderedDict, annotate cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
a-detiste committed Nov 2, 2023
1 parent 0ded533 commit cbe5376
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dokuwiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import base64
import re
import weakref
from collections import OrderedDict
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional, Union
from typing import OrderedDict as t_OrderedDict
Expand Down Expand Up @@ -61,13 +62,13 @@ class CookiesTransport(_TransportClass_):
"""A Python3 xmlrpc.client.Transport subclass that retains cookies."""
def __init__(self) -> None:
super().__init__(self)
self._cookies = dict()
self._cookies: Dict[str, str] = dict()

def send_headers(self, connection, headers: Dict[str, str]) -> None:
if self._cookies:
cookies = map(lambda x: x[0] + '=' + x[1], self._cookies.items())
connection.putheader('Cookie', '; '.join(cookies))
_TransportClass_.send_headers(self, connection, headers)
super().send_headers(self, connection, headers)

def parse_response(self, response):
"""parse and store cookie"""
Expand All @@ -77,7 +78,7 @@ def parse_response(self, response):
cookieKey, cookieValue = cookie.split("=", 1)
self._cookies[cookieKey] = cookieValue
finally:
return _TransportClass_.parse_response(self, response)
return super().parse_response(self, response)

return CookiesTransport()

Expand Down

0 comments on commit cbe5376

Please sign in to comment.